Skip to content

Commit

Permalink
[graphiql] add className prop. Additional class names which will be…
Browse files Browse the repository at this point in the history
… appended to the GraphiQL container element (#3643)
  • Loading branch information
dimaMachina authored Jul 24, 2024
1 parent 88c3d5a commit 82f1ecc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/lazy-beers-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"graphiql": minor
---

add `className` prop. Additional class names which will be appended to the GraphiQL container element
11 changes: 10 additions & 1 deletion packages/graphiql/src/components/GraphiQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ export type GraphiQLInterfaceProps = WriteableEditorProps &
* rendered with a specific theme
*/
forcedTheme?: (typeof THEMES)[number];
/**
* Additional class names which will be appended to the container element.
*/
className?: string;
};

const THEMES = ['light', 'dark', 'system'] as const;
Expand Down Expand Up @@ -465,9 +469,14 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
</Tooltip>
);

const className = props.className ? ` ${props.className}` : '';

return (
<Tooltip.Provider>
<div data-testid="graphiql-container" className="graphiql-container">
<div
data-testid="graphiql-container"
className={`graphiql-container${className}`}
>
<div className="graphiql-sidebar">
<div className="graphiql-sidebar-section">
{pluginContext?.plugins.map((plugin, index) => {
Expand Down

0 comments on commit 82f1ecc

Please sign in to comment.