Skip to content

Commit

Permalink
docs: allow to set a custom label width in demos
Browse files Browse the repository at this point in the history
  • Loading branch information
sebald committed Oct 11, 2024
1 parent caefbe4 commit 1b85f07
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/ui/ComponentDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface ComponentDemoProps {
source: string;
children?: ReactNode;
disableLabelWidth?: boolean;
labelWidth?: string;
}

// Component
Expand All @@ -35,6 +36,7 @@ export const ComponentDemo = ({
name,
children,
disableLabelWidth,
labelWidth = '100px',
}: ComponentDemoProps) => {
if (!registry[name]) {
throw Error(`No demo with name "${name}" found in the registry.`);
Expand All @@ -45,7 +47,7 @@ export const ComponentDemo = ({

const Wrapper = ({ children }: { children: ReactNode }) =>
current === 'core' && !disableLabelWidth ? (
<FieldGroup labelWidth="100px">{children}</FieldGroup>
<FieldGroup labelWidth={labelWidth}>{children}</FieldGroup>
) : (
children
);
Expand Down

0 comments on commit 1b85f07

Please sign in to comment.