본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

레이아웃

원문 보기 위키 갱신

레이아웃 (Layout)

페이지 전체 구조를 잡아 주는 레이아웃 컴포넌트예요. 헤더, 사이드바, 콘텐츠, 푸터를 조합해 안정적인 페이지 골격을 만들어요.

출처: 문서

본문

규격 (Specification)

크기 (Size)

1단계 내비게이션은 로고 근처 왼쪽 정렬이고, 2차 메뉴는 오른쪽 정렬이에요.

  • 상단 내비게이션: 1단계 내비게이션 높이는 64px, 2단계 내비게이션 높이는 48px이에요.
  • 상단 내비게이션 (랜딩 페이지용): 1단계 내비게이션 높이는 80px, 2단계 내비게이션 높이는 56px이에요.
  • 상단 내비게이션 계산 공식: 48+8n.
  • 사이드 내비게이션 계산 공식: 200+8n.

상호작용 규칙 (Interaction rules)

  • 1단계 내비게이션과 마지막 단계 내비게이션은 시각적으로 구분할 수 있어야 해요.
  • 현재 항목은 시각화 우선순위가 가장 높아야 해요.
  • 현재 내비게이션 항목이 접히면 현재 내비게이션 항목의 스타일이 부모 단계에 적용돼요.
  • 왼쪽 사이드 내비게이션 바는 아코디언과 확장 스타일을 모두 지원해요. 상황에 가장 잘 맞는 것을 선택하면 돼요.

시각화 규칙 (Visualization rules)

내비게이션 스타일은 그 단계에 맞아야 해요.

  • 색 블록으로 강조 (Emphasis by colorblock)

    배경색이 진한 색일 때, 현재 페이지의 부모 단계 내비게이션 항목에 이 패턴을 사용할 수 있어요.

  • 하이라이트 매치 스틱 (The highlight match stick)

    배경색이 밝은 색일 때, 현재 페이지 내비게이션 항목에 이 패턴을 사용할 수 있어요. 내비게이션 경로의 마지막 항목에 사용하는 것을 권장해요.

  • 강조된 글꼴 (Highlighted font)

    시각적 측면에서 강조된 글꼴은 색 블록보다 강해요. 이 패턴은 현재 항목의 부모 단계에 자주 쓰여요.

  • 글꼴 크기 확대 (Enlarge the size of the font)

    12px, 14px는 내비게이션의 표준 글자 크기예요. 14px는 내비게이션의 1단계와 2단계에 사용돼요. 내비게이션의 단계에 따라 적절한 글자 크기를 선택할 수 있어요.

컴포넌트 개요 (Component Overview)

  • Layout: 레이아웃 래퍼예요. 그 안에 Header, Sider, Content, Footer 또는 Layout 자체를 중첩할 수 있고, 어떤 부모 컨테이너에도 놓을 수 있어요.
  • Header: 기본 스타일의 상단 레이아웃이에요. 어떤 요소도 중첩할 수 있으며 Layout 안에 배치해야 해요.
  • Sider: 기본 스타일과 기본 기능을 가진 사이드바예요. 어떤 요소도 중첩할 수 있으며 Layout 안에 배치해야 해요.
  • Content: 기본 스타일의 콘텐츠 레이아웃이에요. 어떤 요소도 중첩할 수 있으며 Layout 안에 배치해야 해요.
  • Footer: 기본 스타일의 하단 레이아웃이에요. 어떤 요소도 중첩할 수 있으며 Layout 안에 배치해야 해요.

flex layout을 기반으로 하므로 호환성에 주의해 주세요.

예시 (Examples)

기본 구조 (Basic Structure)

클래식한 페이지 레이아웃이에요.

import React from 'react';
import { Flex, Layout } from 'antd';

const { Header, Footer, Sider, Content } = Layout;

const headerStyle: React.CSSProperties = {
  textAlign: 'center',
  color: '#fff',
  height: 64,
  paddingInline: 48,
  lineHeight: '64px',
  backgroundColor: '#4096ff',
};

const contentStyle: React.CSSProperties = {
  textAlign: 'center',
  minHeight: 120,
  lineHeight: '120px',
  color: '#fff',
  backgroundColor: '#0958d9',
};

const siderStyle: React.CSSProperties = {
  textAlign: 'center',
  lineHeight: '120px',
  color: '#fff',
  backgroundColor: '#1677ff',
};

const footerStyle: React.CSSProperties = {
  textAlign: 'center',
  color: '#fff',
  backgroundColor: '#4096ff',
};

const layoutStyle = {
  borderRadius: 8,
  overflow: 'hidden',
  width: 'calc(50% - 8px)',
  maxWidth: 'calc(50% - 8px)',
};

const App: React.FC = () => (
  <Flex gap="medium" wrap>
    <Layout style={layoutStyle}>
      <Header style={headerStyle}>Header</Header>
      <Content style={contentStyle}>Content</Content>
      <Footer style={footerStyle}>Footer</Footer>
    </Layout>

    <Layout style={layoutStyle}>
      <Header style={headerStyle}>Header</Header>
      <Layout>
        <Sider width="25%" style={siderStyle}>
          Sider
        </Sider>
        <Content style={contentStyle}>Content</Content>
      </Layout>
      <Footer style={footerStyle}>Footer</Footer>
    </Layout>

    <Layout style={layoutStyle}>
      <Header style={headerStyle}>Header</Header>
      <Layout>
        <Content style={contentStyle}>Content</Content>
        <Sider width="25%" style={siderStyle}>
          Sider
        </Sider>
      </Layout>
      <Footer style={footerStyle}>Footer</Footer>
    </Layout>

    <Layout style={layoutStyle}>
      <Sider width="25%" style={siderStyle}>
        Sider
      </Sider>
      <Layout>
        <Header style={headerStyle}>Header</Header>
        <Content style={contentStyle}>Content</Content>
        <Footer style={footerStyle}>Footer</Footer>
      </Layout>
    </Layout>
  </Flex>
);

export default App;

가장 기본적인 "header-content-footer" 레이아웃이에요.

일반적으로 메인 내비게이션은 페이지 상단에 놓이며 로고, 1단계 내비게이션, 2차 메뉴(사용자, 설정, 알림)를 왼쪽에서 오른쪽으로 포함해요. 콘텐츠는 항상 고정 크기 내비게이션(예: 1200px)에 넣기 때문에 전체 페이지 레이아웃이 안정적이고, 보기 영역의 영향을 받지 않아요.

상하 구조는 상하 보기 습관과 일치하는 웹사이트의 전형적인 내비게이션 패턴이에요. 이 패턴은 세로 공간을 사용하면서도 주요 작업 영역에서 효율성을 보여 줘요. 하지만 내비게이션의 가로 공간이 제한적이어서, 1단계 내비게이션에 요소나 링크가 많을 때는 적합하지 않아요.

import React from 'react';
import { Breadcrumb, Layout, Menu, theme } from 'antd';

const { Header, Content, Footer } = Layout;

const items = Array.from({ length: 15 }).map((_, index) => ({
  key: index + 1,
  label: `nav ${index + 1}`,
}));

const App: React.FC = () => {
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();

  const currentYear = new Date().getFullYear();

  return (
    <Layout>
      <Header style={{ display: 'flex', alignItems: 'center' }}>
        <div className="demo-logo" />
        <Menu
          theme="dark"
          mode="horizontal"
          defaultSelectedKeys={['2']}
          items={items}
          style={{ flex: 1, minWidth: 0 }}
        />
      </Header>
      <Content style={{ padding: '0 48px' }}>
        <Breadcrumb
          style={{ margin: '16px 0' }}
          items={[{ title: 'Home' }, { title: 'List' }, { title: 'App' }]}
        />
        <div
          style={{
            background: colorBgContainer,
            minHeight: 280,
            padding: 24,
            borderRadius: borderRadiusLG,
          }}
        >
          Content
        </div>
      </Content>
      <Footer style={{ textAlign: 'center' }}>Ant Design ©{currentYear} Created by Ant UED</Footer>
    </Layout>
  );
};

export default App;

Header-Sider

상단 내비게이션과 사이드바를 함께 쓰는, 문서 사이트에서 흔한 구성이에요.

import React from 'react';
import { LaptopOutlined, NotificationOutlined, UserOutlined } from '@ant-design/icons';
import type { MenuProps } from 'antd';
import { Breadcrumb, Layout, Menu, theme } from 'antd';

const { Header, Content, Footer, Sider } = Layout;

const items1: MenuProps['items'] = ['1', '2', '3'].map((key) => ({
  key,
  label: `nav ${key}`,
}));

const items2: MenuProps['items'] = [UserOutlined, LaptopOutlined, NotificationOutlined].map(
  (icon, index) => {
    const key = String(index + 1);

    return {
      key: `sub${key}`,
      icon: React.createElement(icon),
      label: `subnav ${key}`,
      children: Array.from({ length: 4 }).map((_, j) => {
        const subKey = index * 4 + j + 1;
        return {
          key: subKey,
          label: `option${subKey}`,
        };
      }),
    };
  },
);

const App: React.FC = () => {
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();

  const currentYear = new Date().getFullYear();

  return (
    <Layout>
      <Header style={{ display: 'flex', alignItems: 'center' }}>
        <div className="demo-logo" />
        <Menu
          theme="dark"
          mode="horizontal"
          defaultSelectedKeys={['2']}
          items={items1}
          style={{ flex: 1, minWidth: 0 }}
        />
      </Header>
      <div style={{ padding: '0 48px' }}>
        <Breadcrumb
          style={{ margin: '16px 0' }}
          items={[{ title: 'Home' }, { title: 'List' }, { title: 'App' }]}
        />
        <Layout
          style={{ padding: '24px 0', background: colorBgContainer, borderRadius: borderRadiusLG }}
        >
          <Sider style={{ background: colorBgContainer }} width={200}>
            <Menu
              mode="inline"
              defaultSelectedKeys={['1']}
              defaultOpenKeys={['sub1']}
              style={{ height: '100%' }}
              items={items2}
            />
          </Sider>
          <Content style={{ padding: '0 24px', minHeight: 280 }}>Content</Content>
        </Layout>
      </div>
      <Footer style={{ textAlign: 'center' }}>Ant Design ©{currentYear} Created by Ant UED</Footer>
    </Layout>
  );
};

export default App;

Header Sider 2

상단 내비게이션과 사이드바를 함께 쓰는, 애플리케이션 사이트에서 흔한 구성이에요.

import React from 'react';
import { LaptopOutlined, NotificationOutlined, UserOutlined } from '@ant-design/icons';
import type { MenuProps } from 'antd';
import { Breadcrumb, Layout, Menu, theme } from 'antd';

const { Header, Content, Sider } = Layout;

const items1: MenuProps['items'] = ['1', '2', '3'].map((key) => ({
  key,
  label: `nav ${key}`,
}));

const items2: MenuProps['items'] = [UserOutlined, LaptopOutlined, NotificationOutlined].map(
  (icon, index) => {
    const key = String(index + 1);

    return {
      key: `sub${key}`,
      icon: React.createElement(icon),
      label: `subnav ${key}`,
      children: Array.from({ length: 4 }).map((_, j) => {
        const subKey = index * 4 + j + 1;
        return {
          key: subKey,
          label: `option${subKey}`,
        };
      }),
    };
  },
);

const App: React.FC = () => {
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();

  return (
    <Layout>
      <Header style={{ display: 'flex', alignItems: 'center' }}>
        <div className="demo-logo" />
        <Menu
          theme="dark"
          mode="horizontal"
          defaultSelectedKeys={['2']}
          items={items1}
          style={{ flex: 1, minWidth: 0 }}
        />
      </Header>
      <Layout>
        <Sider width={200} style={{ background: colorBgContainer }}>
          <Menu
            mode="inline"
            defaultSelectedKeys={['1']}
            defaultOpenKeys={['sub1']}
            style={{ height: '100%', borderInlineEnd: 0 }}
            items={items2}
          />
        </Sider>
        <Layout style={{ padding: '0 24px 24px' }}>
          <Breadcrumb
            items={[{ title: 'Home' }, { title: 'List' }, { title: 'App' }]}
            style={{ margin: '16px 0' }}
          />
          <Content
            style={{
              padding: 24,
              margin: 0,
              minHeight: 280,
              background: colorBgContainer,
              borderRadius: borderRadiusLG,
            }}
          >
            Content
          </Content>
        </Layout>
      </Layout>
    </Layout>
  );
};

export default App;

Sider

2열 레이아웃이에요. 가로 공간이 제한될 때 sider 메뉴를 접을 수 있어요.

일반적으로 메인 내비게이션은 페이지 왼쪽에, 2차 메뉴는 작업 영역 위쪽에 배치해요. 콘텐츠는 보기 영역에 맞춰 레이아웃을 조정해 가로 공간 사용을 높이지만, 전체 페이지 레이아웃은 안정적이지 않아요.

사이드 내비게이션의 단계는 확장 가능해요. 1단계, 2단계, 3단계 내비게이션을 더 유연하고 관련성 있게 제공할 수 있고, 사이드 내비게이션을 고정하면 사용자가 현재 위치를 빠르게 전환하고 찾을 수 있어 사용자 경험이 좋아져요. 다만 이 내비게이션은 콘텐츠의 가로 공간 일부를 차지해요.

import React, { useState } from 'react';
import {
  DesktopOutlined,
  FileOutlined,
  PieChartOutlined,
  TeamOutlined,
  UserOutlined,
} from '@ant-design/icons';
import type { MenuProps } from 'antd';
import { Breadcrumb, Layout, Menu, theme } from 'antd';

const { Header, Content, Footer, Sider } = Layout;

type MenuItem = Required<MenuProps>['items'][number];

function getItem(
  label: React.ReactNode,
  key: React.Key,
  icon?: React.ReactNode,
  children?: MenuItem[],
): MenuItem {
  return {
    key,
    icon,
    children,
    label,
  } as MenuItem;
}

const items: MenuItem[] = [
  getItem('Option 1', '1', <PieChartOutlined />),
  getItem('Option 2', '2', <DesktopOutlined />),
  getItem('User', 'sub1', <UserOutlined />, [
    getItem('Tom', '3'),
    getItem('Bill', '4'),
    getItem('Alex', '5'),
  ]),
  getItem('Team', 'sub2', <TeamOutlined />, [getItem('Team 1', '6'), getItem('Team 2', '8')]),
  getItem('Files', '9', <FileOutlined />),
];

const App: React.FC = () => {
  const [collapsed, setCollapsed] = useState(false);
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();

  const currentYear = new Date().getFullYear();

  return (
    <Layout style={{ minHeight: '100vh' }}>
      <Sider collapsible collapsed={collapsed} onCollapse={(value) => setCollapsed(value)}>
        <div className="demo-logo-vertical" />
        <Menu theme="dark" defaultSelectedKeys={['1']} mode="inline" items={items} />
      </Sider>
      <Layout>
        <Header style={{ padding: 0, background: colorBgContainer }} />
        <Content style={{ margin: '0 16px' }}>
          <Breadcrumb style={{ margin: '16px 0' }} items={[{ title: 'User' }, { title: 'Bill' }]} />
          <div
            style={{
              padding: 24,
              minHeight: 360,
              background: colorBgContainer,
              borderRadius: borderRadiusLG,
            }}
          >
            Bill is a cat.
          </div>
        </Content>
        <Footer style={{ textAlign: 'center' }}>
          Ant Design ©{currentYear} Created by Ant UED
        </Footer>
      </Layout>
    </Layout>
  );
};

export default App;

커스텀 트리거 (Custom trigger)

커스터마이즈된 트리거를 사용하고 싶다면 trigger={null}로 기본 트리거를 숨길 수 있어요.

import React, { useState } from 'react';
import {
  MenuFoldOutlined,
  MenuUnfoldOutlined,
  UploadOutlined,
  UserOutlined,
  VideoCameraOutlined,
} from '@ant-design/icons';
import { Button, Layout, Menu, theme } from 'antd';

const { Header, Sider, Content } = Layout;

const App: React.FC = () => {
  const [collapsed, setCollapsed] = useState(false);
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();

  return (
    <Layout>
      <Sider trigger={null} collapsible collapsed={collapsed}>
        <div className="demo-logo-vertical" />
        <Menu
          theme="dark"
          mode="inline"
          defaultSelectedKeys={['1']}
          items={[
            {
              key: '1',
              icon: <UserOutlined />,
              label: 'nav 1',
            },
            {
              key: '2',
              icon: <VideoCameraOutlined />,
              label: 'nav 2',
            },
            {
              key: '3',
              icon: <UploadOutlined />,
              label: 'nav 3',
            },
          ]}
        />
      </Sider>
      <Layout>
        <Header style={{ padding: 0, background: colorBgContainer }}>
          <Button
            type="text"
            icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
            onClick={() => setCollapsed(!collapsed)}
            style={{
              fontSize: '16px',
              width: 64,
              height: 64,
            }}
          />
        </Header>
        <Content
          style={{
            margin: '24px 16px',
            padding: 24,
            minHeight: 280,
            background: colorBgContainer,
            borderRadius: borderRadiusLG,
          }}
        >
          Content
        </Content>
      </Layout>
    </Layout>
  );
};

export default App;

접히는 오버레이 (Collapsible overlay)

Sider 가장자리에 붙은 커스텀 트리거로 접거나 펼쳐요. 펼쳐진 Sider는 문서 흐름을 벗어나 비즈니스 스타일로 콘텐츠를 덮을 수 있어, 콘텐츠 영역이 눌리지 않게 해요.

import React from 'react';
import {
  DesktopOutlined,
  FileOutlined,
  MenuFoldOutlined,
  MenuUnfoldOutlined,
  PieChartOutlined,
  TeamOutlined,
} from '@ant-design/icons';
import type { MenuProps } from 'antd';
import { Layout, Menu, theme } from 'antd';

const { Header, Content, Footer, Sider } = Layout;

const layoutStyle: React.CSSProperties = {
  position: 'relative',
  minHeight: 360,
};

const siderStyle: React.CSSProperties = {
  position: 'absolute',
  top: 0,
  bottom: 0,
  insetInlineStart: 0,
  zIndex: 10,
};

const items: MenuProps['items'] = [
  PieChartOutlined,
  DesktopOutlined,
  TeamOutlined,
  FileOutlined,
].map((icon, index) => ({
  key: String(index + 1),
  icon: React.createElement(icon),
  label: `nav ${index + 1}`,
}));

const App: React.FC = () => {
  const [collapsed, setCollapsed] = React.useState(false);
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();

  const currentYear = new Date().getFullYear();

  return (
    <Layout style={layoutStyle}>
      <Sider
        collapsible
        collapsed={collapsed}
        collapsedWidth="0"
        style={siderStyle}
        trigger={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
        onCollapse={setCollapsed}
      >
        <div className="demo-logo-vertical" />
        <Menu theme="dark" mode="inline" defaultSelectedKeys={['1']} items={items} />
      </Sider>
      <Layout>
        <Header
          style={{
            padding: 0,
            background: colorBgContainer,
          }}
        />
        <Content style={{ margin: '24px 16px 0' }}>
          <div
            style={{
              padding: 24,
              minHeight: 240,
              background: colorBgContainer,
              borderRadius: borderRadiusLG,
            }}
          >
            Content keeps its full width when the sider overlays it.
          </div>
        </Content>
        <Footer style={{ textAlign: 'center' }}>
          Ant Design ©{currentYear} Created by Ant UED
        </Footer>
      </Layout>
    </Layout>
  );
};

export default App;

반응형 (Responsive)

Layout.Sider는 반응형 레이아웃을 지원해요.

참고: breakpoint를 설정하면 반응형 레이아웃을 얻을 수 있어요. 창 너비가 breakpoint보다 낮아지면 Sider가 collapsedWidth 너비로 접혀요. 그리고 collapsedWidth를 0으로 설정하면 특별한 트리거가 나타나요.

import React from 'react';
import { UploadOutlined, UserOutlined, VideoCameraOutlined } from '@ant-design/icons';
import { Layout, Menu, theme } from 'antd';

const { Header, Content, Footer, Sider } = Layout;

const items = [UserOutlined, VideoCameraOutlined, UploadOutlined, UserOutlined].map(
  (icon, index) => ({
    key: String(index + 1),
    icon: React.createElement(icon),
    label: `nav ${index + 1}`,
  }),
);

const App: React.FC = () => {
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();

  const currentYear = new Date().getFullYear();

  return (
    <Layout>
      <Sider
        breakpoint="lg"
        collapsedWidth="0"
        onBreakpoint={(broken) => {
          console.log(broken);
        }}
        onCollapse={(collapsed, type) => {
          console.log(collapsed, type);
        }}
      >
        <div className="demo-logo-vertical" />
        <Menu theme="dark" mode="inline" defaultSelectedKeys={['4']} items={items} />
      </Sider>
      <Layout>
        <Header style={{ padding: 0, background: colorBgContainer }} />
        <Content style={{ margin: '24px 16px 0' }}>
          <div
            style={{
              padding: 24,
              minHeight: 360,
              background: colorBgContainer,
              borderRadius: borderRadiusLG,
            }}
          >
            content
          </div>
        </Content>
        <Footer style={{ textAlign: 'center' }}>
          Ant Design ©{currentYear} Created by Ant UED
        </Footer>
      </Layout>
    </Layout>
  );
};

export default App;

고정 헤더 (Fixed Header)

Sticky Header는 보통 상단 내비게이션을 고정해 페이지 전환을 쉽게 하는 데 사용돼요.

import React from 'react';
import { Breadcrumb, Layout, Menu, theme } from 'antd';

const { Header, Content, Footer } = Layout;

const items = Array.from({ length: 3 }).map((_, index) => ({
  key: String(index + 1),
  label: `nav ${index + 1}`,
}));

const App: React.FC = () => {
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();

  const currentYear = new Date().getFullYear();

  return (
    <Layout>
      <Header
        style={{
          position: 'sticky',
          top: 0,
          zIndex: 1,
          width: '100%',
          display: 'flex',
          alignItems: 'center',
        }}
      >
        <div className="demo-logo" />
        <Menu
          theme="dark"
          mode="horizontal"
          defaultSelectedKeys={['2']}
          items={items}
          style={{ flex: 1, minWidth: 0 }}
        />
      </Header>
      <Content style={{ padding: '0 48px' }}>
        <Breadcrumb
          style={{ margin: '16px 0' }}
          items={[{ title: 'Home' }, { title: 'List' }, { title: 'App' }]}
        />
        <div
          style={{
            padding: 24,
            minHeight: 380,
            background: colorBgContainer,
            borderRadius: borderRadiusLG,
          }}
        >
          Content
        </div>
      </Content>
      <Footer style={{ textAlign: 'center' }}>Ant Design ©{currentYear} Created by Ant UED</Footer>
    </Layout>
  );
};

export default App;

고정 Sider (Fixed Sider)

긴 콘텐츠를 다룰 때 스티키 sider는 더 나은 사용자 경험을 제공할 수 있어요.

import React from 'react';
import {
  AppstoreOutlined,
  BarChartOutlined,
  CloudOutlined,
  ShopOutlined,
  TeamOutlined,
  UploadOutlined,
  UserOutlined,
  VideoCameraOutlined,
} from '@ant-design/icons';
import type { MenuProps } from 'antd';
import { Layout, Menu, theme } from 'antd';

const { Header, Content, Footer, Sider } = Layout;

const siderStyle: React.CSSProperties = {
  overflow: 'auto',
  height: '100vh',
  position: 'sticky',
  insetInlineStart: 0,
  top: 0,
  scrollbarWidth: 'thin',
  scrollbarGutter: 'stable',
};

const items: MenuProps['items'] = [
  UserOutlined,
  VideoCameraOutlined,
  UploadOutlined,
  BarChartOutlined,
  CloudOutlined,
  AppstoreOutlined,
  TeamOutlined,
  ShopOutlined,
].map((icon, index) => ({
  key: String(index + 1),
  icon: React.createElement(icon),
  label: `nav ${index + 1}`,
}));

const App: React.FC = () => {
  const {
    token: { colorBgContainer, borderRadiusLG },
  } = theme.useToken();
  const currentYear = new Date().getFullYear();

  return (
    <Layout hasSider>
      <Sider style={siderStyle}>
        <div className="demo-logo-vertical" />
        <Menu theme="dark" mode="inline" defaultSelectedKeys={['4']} items={items} />
      </Sider>
      <Layout>
        <Header style={{ padding: 0, background: colorBgContainer }} />
        <Content style={{ margin: '24px 16px 0', overflow: 'initial' }}>
          <div
            style={{
              padding: 24,
              textAlign: 'center',
              background: colorBgContainer,
              borderRadius: borderRadiusLG,
            }}
          >
            <p>long content</p>
            {
              // indicates very long content
              Array.from({ length: 100 }, (_, index) => (
                <React.Fragment key={index}>
                  {index % 20 === 0 && index ? 'more' : '...'}
                  <br />
                </React.Fragment>
              ))
            }
          </div>
        </Content>
        <Footer style={{ textAlign: 'center' }}>
          Ant Design ©{currentYear} Created by Ant UED
        </Footer>
      </Layout>
    </Layout>
  );
};

export default App;

API

<Layout>
  <Header>header</Header>
  <Layout>
    <Sider>left sidebar</Sider>
    <Content>main content</Content>
    <Sider>right sidebar</Sider>
  </Layout>
  <Footer>footer</Footer>
</Layout>

Layout

공통 props는 Common props를 참고해요.

래퍼예요.

속성 (Property) 설명 (Description) 타입 (Type) 기본값 (Default) 버전 (Version) 글로벌 설정
hasSider children에 Sider가 포함되는지 여부예요. 보통 할당할 필요가 없어요. ssr에서 스타일 깜빡임을 피하는 데 유용해요. boolean - ×

Layout.Sider

사이드바예요.

속성 (Property) 설명 (Description) 타입 (Type) 기본값 (Default) 버전 (Version)
breakpoint 반응형 레이아웃의 Breakpoints xs | sm | md | lg | xl | xxl | xxxl - xxxl: 6.3.0
classNames Sider 컴포넌트 내부의 각 시맨틱 구조에 대한 class를 지정해요. 객체 또는 함수를 지원해요. Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string> -
collapsed 현재 상태를 설정해요. boolean -
collapsedWidth 접힌 사이드바의 너비예요. 0으로 설정하면 특별한 트리거가 나타나요. number 80
collapsible 접을 수 있는지 여부 boolean false
defaultCollapsed 초기 상태를 설정해요. boolean false
reverseArrow 화살표 방향을 반대로 해요. 오른쪽에서 확장되는 sider용. boolean false
styles Sider 컴포넌트 내부의 각 시맨틱 구조에 대한 인라인 스타일을 지정해요. 객체 또는 함수를 지원해요. Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties> -
theme 사이드바의 색 테마 light | dark dark
trigger 커스터마이즈된 트리거를 지정해요. null로 설정하면 트리거를 숨겨요. ReactNode -
width 사이드바의 너비 number | string 200
zeroWidthTriggerStyle collapsedWidth가 0일 때 나타나는 특별한 트리거의 스타일을 커스터마이즈해요. object -
onBreakpoint breakpoints가 변경될 때 실행되는 콜백 함수 (broken) => {} -
onCollapse 트리거를 클릭하거나 반응형 레이아웃이 활성화될 때 실행되는 콜백 함수 (collapsed, type) => {} -

시맨틱 DOM (Semantic DOM)

시맨틱 DOM 구조는 https://ant.design/components/layout/semantic.md 에서 확인할 수 있어요.

breakpoint 너비 (breakpoint width)

{
  xs: '480px',
  sm: '576px',
  md: '768px',
  lg: '992px',
  xl: '1200px',
  xxl: '1600px',
  xxxl: '1920px',
}

디자인 토큰 (Design Token)

컴포넌트 토큰 (Layout) (Component Token)

토큰 이름 (Token Name) 설명 (Description) 타입 (Type) 기본값 (Default Value)
bodyBg body의 배경색 string #f5f5f5
footerBg footer의 배경색 string #f5f5f5
footerPadding footer의 패딩 Padding<string | number> | undefined 24px 50px
headerBg header의 배경색 string #001529
headerColor header의 텍스트 색 string rgba(0,0,0,0.88)
headerHeight header의 높이 string | number 64
headerPadding header의 패딩 Padding<string | number> | undefined 0 50px
lightSiderBg 라이트 테마 sider의 배경색 string #ffffff
lightTriggerBg 라이트 테마 sider trigger의 배경색 string #ffffff
lightTriggerColor 라이트 테마 sider trigger의 색 string rgba(0,0,0,0.88)
siderBg sider의 배경색 string #001529
triggerBg sider trigger의 배경색 string #002140
triggerColor sider trigger의 색 string #fff
triggerHeight sider trigger의 높이 string | number 48
zeroTriggerHeight collapse가 0일 때 sider trigger의 높이 number 40
zeroTriggerWidth collapse가 0일 때 sider trigger의 너비 number 40

글로벌 토큰 (Global Token)

토큰 이름 (Token Name) 설명 (Description) 타입 (Type) 기본값 (Default Value)
colorText W3C 표준을 따르는 기본 텍스트 색이에요. 가장 어두운 중성색이기도 해요. string
fontSize 디자인 시스템에서 가장 널리 쓰이는 글자 크기로, 여기서 텍스트 그라데이션이 파생돼요. number

더 알아보기 (Learn more)