Import
import { Layout } from '@contentful/f36-components';
import { Layout } from '@contentful/f36-layout';
Examples
function BasicLayoutExample() {
const [submitting, setSubmitting] = useState(false);
const submitForm = () => {
setSubmitting(true);
setTimeout(() => setSubmitting(false), 1000);
};
return (
<Layout
className={css({
backgroundColor: tokens.gray100,
})}
header={
<Layout.Header>
<Heading marginTop="spacingM" marginBottom="spacingM">
Your Details
</Heading>
</Layout.Header>
}
leftSidebar={
<Layout.Sidebar>
<Box padding="none" marginBottom="spacingXl">
<Paragraph>Sidebar Content</Paragraph>
</Box>
</Layout.Sidebar>
}
rightSidebar={
<Layout.Sidebar>
<Box padding="none" marginBottom="spacingXl">
<Paragraph>Sidebar Content</Paragraph>
</Box>
</Layout.Sidebar>
}
>
<Layout.Body>
<Box padding="none" marginBottom="spacingXl">
<Form onSubmit={submitForm}>
<FormControl>
<FormControl.Label isRequired>Name</FormControl.Label>
<TextInput />
<FormControl.HelpText>
Please enter your first name
</FormControl.HelpText>
</FormControl>
<FormControl>
<FormControl.Label>Description</FormControl.Label>
<Textarea />
<FormControl.HelpText>
Tell me about yourself
</FormControl.HelpText>
</FormControl>
<Button variant="primary" type="submit" isDisabled={submitting}>
{submitting ? 'Submitted' : 'Click me to submit'}
</Button>
</Form>
</Box>
</Layout.Body>
</Layout>
);
}
function BasicLayoutExample() {
const [submitting, setSubmitting] = useState(false);
const submitForm = () => {
setSubmitting(true);
setTimeout(() => setSubmitting(false), 1000);
};
return (
<Layout
variant="fullscreen"
className={css({
backgroundColor: tokens.gray100,
})}
header={
<Layout.Header>
<Heading marginTop="spacingM" marginBottom="spacingM">
Your Details
</Heading>
</Layout.Header>
}
leftSidebar={
<Layout.Sidebar>
<Box padding="none" marginBottom="spacingXl">
<Paragraph>Sidebar Content</Paragraph>
</Box>
</Layout.Sidebar>
}
rightSidebar={
<Layout.Sidebar>
<Box padding="none" marginBottom="spacingXl">
<Paragraph>Sidebar Content</Paragraph>
</Box>
</Layout.Sidebar>
}
>
<Layout.Body>
<Box padding="none" marginBottom="spacingXl">
<Form onSubmit={submitForm}>
<FormControl>
<FormControl.Label isRequired>Name</FormControl.Label>
<TextInput />
<FormControl.HelpText>
Please enter your first name
</FormControl.HelpText>
</FormControl>
<FormControl>
<FormControl.Label>Description</FormControl.Label>
<Textarea />
<FormControl.HelpText>
Tell me about yourself
</FormControl.HelpText>
</FormControl>
<Button variant="primary" type="submit" isDisabled={submitting}>
{submitting ? 'Submitted' : 'Click me to submit'}
</Button>
</Form>
</Box>
</Layout.Body>
</Layout>
);
}
Basic Layout with body only
function BasicLayoutExample() {
const [submitting, setSubmitting] = useState(false);
const submitForm = () => {
setSubmitting(true);
setTimeout(() => setSubmitting(false), 1000);
};
return (
<Layout
className={css({
backgroundColor: tokens.gray100,
})}
>
<Layout.Body>
<Box padding="none" marginBottom="spacingXl">
<Form onSubmit={submitForm}>
<FormControl>
<FormControl.Label isRequired>Name</FormControl.Label>
<TextInput />
<FormControl.HelpText>
Please enter your first name
</FormControl.HelpText>
</FormControl>
<FormControl>
<FormControl.Label>Description</FormControl.Label>
<Textarea />
<FormControl.HelpText>
Tell me about yourself
</FormControl.HelpText>
</FormControl>
<Button variant="primary" type="submit" isDisabled={submitting}>
{submitting ? 'Submitted' : 'Click me to submit'}
</Button>
</Form>
</Box>
</Layout.Body>
</Layout>
);
}
function BasicLayoutExample() {
const [submitting, setSubmitting] = useState(false);
const submitForm = () => {
setSubmitting(true);
setTimeout(() => setSubmitting(false), 1000);
};
return (
<Layout
className={css({
backgroundColor: tokens.gray100,
})}
header={
<Layout.Header>
<Heading marginTop="spacingM" marginBottom="spacingM">
Your Details
</Heading>
</Layout.Header>
}
>
<Layout.Body>
<Box padding="none" marginBottom="spacingXl">
<Form onSubmit={submitForm}>
<FormControl>
<FormControl.Label isRequired>Name</FormControl.Label>
<TextInput />
<FormControl.HelpText>
Please enter your first name
</FormControl.HelpText>
</FormControl>
<FormControl>
<FormControl.Label>Description</FormControl.Label>
<Textarea />
<FormControl.HelpText>
Tell me about yourself
</FormControl.HelpText>
</FormControl>
<Button variant="primary" type="submit" isDisabled={submitting}>
{submitting ? 'Submitted' : 'Click me to submit'}
</Button>
</Form>
</Box>
</Layout.Body>
</Layout>
);
}
function BasicLayoutExample() {
const [submitting, setSubmitting] = useState(false);
const submitForm = () => {
setSubmitting(true);
setTimeout(() => setSubmitting(false), 1000);
};
return (
<Layout
className={css({
backgroundColor: tokens.gray100,
})}
leftSidebar={
<Layout.Sidebar>
<Box padding="none" marginBottom="spacingXl">
<Paragraph>Sidebar Content</Paragraph>
</Box>
</Layout.Sidebar>
}
>
<Layout.Body>
<Box padding="none" marginBottom="spacingXl">
<Form onSubmit={submitForm}>
<FormControl>
<FormControl.Label isRequired>Name</FormControl.Label>
<TextInput />
<FormControl.HelpText>
Please enter your first name
</FormControl.HelpText>
</FormControl>
<FormControl>
<FormControl.Label>Description</FormControl.Label>
<Textarea />
<FormControl.HelpText>
Tell me about yourself
</FormControl.HelpText>
</FormControl>
<Button variant="primary" type="submit" isDisabled={submitting}>
{submitting ? 'Submitted' : 'Click me to submit'}
</Button>
</Form>
</Box>
</Layout.Body>
</Layout>
);
}
function BasicLayoutExample() {
const [submitting, setSubmitting] = useState(false);
const submitForm = () => {
setSubmitting(true);
setTimeout(() => setSubmitting(false), 1000);
};
return (
<Layout
className={css({
backgroundColor: tokens.gray100,
})}
rightSidebar={
<Layout.Sidebar>
<Box padding="none" marginBottom="spacingXl">
<Paragraph>Sidebar Content</Paragraph>
</Box>
</Layout.Sidebar>
}
>
<Layout.Body>
<Box padding="none" marginBottom="spacingXl">
<Form onSubmit={submitForm}>
<FormControl>
<FormControl.Label isRequired>Name</FormControl.Label>
<TextInput />
<FormControl.HelpText>
Please enter your first name
</FormControl.HelpText>
</FormControl>
<FormControl>
<FormControl.Label>Description</FormControl.Label>
<Textarea />
<FormControl.HelpText>
Tell me about yourself
</FormControl.HelpText>
</FormControl>
<Button variant="primary" type="submit" isDisabled={submitting}>
{submitting ? 'Submitted' : 'Click me to submit'}
</Button>
</Form>
</Box>
</Layout.Body>
</Layout>
);
}
Name | Type | Default |
---|
children | ReactNode The body of the layout. | |
className | string CSS class to be appended to the root element | |
contentClassName | string Classname that will be passed to the main content div,
which holds the sidebars and children div | |
contentTestId | string | |
css | string number false true ComponentSelector Keyframes SerializedStyles ArrayInterpolation<undefined> ObjectInterpolation<undefined> (theme: any) => Interpolation<undefined> | |
header | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal | |
leftSidebar | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal | |
rightSidebar | string number false true {} ReactElement<any, string | JSXElementConstructor<any>> ReactNodeArray ReactPortal | |
testId | string A [data-test-id] attribute used for testing purposes | |
variant | "narrow" "wide" "fullscreen" Defines the width of the layout and its content. | 'wide' |
withBoxShadow | false true | |