Discover the Delicate Beauty of Components with Semantic Design — 시맨틱 디자인으로 컴포넌트의 섬세한 아름다움 발견하기
Ant Design v6 이전에는 토큰을 기반으로 스타일을 커스터마이징하는 경험이 이미 훌륭했지만, 해결하기 어려운 고통 지점이 몇 가지 있었어요. v6는 이를 해결하기 위해 많은 변화와 개선을 만들었어요. 이 글에서는 시맨틱 디자인이 어떻게 컴포넌트의 섬세한 아름다움을 발견하게 해주는지 설명해 드릴게요.
출처: 문서
본문
Ant Design v6 이전에는 오픈 토큰을 기반으로 스타일을 커스터마이징하는 경험이 이미 좋았지만, 여전히 해결하기 어려운 몇 가지 고통 지점이 있었어요. Ant Design v6는 이를 해결하기 위해 많은 변화와 개선을 만들었어요. 오늘은 시맨틱 디자인이 어떻게 컴포넌트의 섬세한 아름다움을 발견하게 해주는지 이야기해 볼게요.
v6 이전
과거에는 보통 어떻게 컴포넌트 스타일을 조정했을까요?
방법 1 (props)
className과style속성에서 조합을 위한 광범위한 조건 로직 작성- 다른 컴포넌트 영역의 스타일을 수정할 때
wrapClassName같은 수많은 props 사용
코드는 이렇게 생겼을 거예요:
<Button className={variant === 'filled' ? 'btn-filled' : 'btn-outline'}>
Submit
</Button>
<Modal wrapClassName="wrap-class" style={{ backgroundColor: '#fff' }}>
Modal
</Modal>
<Menu style={{ backgroundColor: mode === 'horizontal' ? '#fff' : '#000' }}>
<Menu.SubMenu popupClassName="popup-class">
<Menu.Item >
MenuItem
</Menu.Item>
</Menu.SubMenu>
</Menu>
방법 2 (ConfigProvider)
Ant Design v5에서 도입된 테마 Design Token 디자인 사용:
<ConfigProvider
theme={{
components: {
Notification: {
colorTextHeading: token.blue,
colorText: token.colorTextSecondary,
},
},
}}
>
{children}
</ConfigProvider>
방법 3 (CSS)
이 두 방법 외에도, 별로 권장되지 않는 CSS 오버라이드를 작성했을 수도 있어요:
.wrapper-class .ant-table {
border-radius: 4px;
overflow: hidden;
}
.wrapper-class .ant-table .ant-table-thead {
background-color: #f9fafc;
color: #8b97b6;
}
위의 모든 방식에는 여러 고통 지점이 있어요:
- 사용 가능한
props가 제한되어 특정 영역을 수정할 수 없고, 로직도 잘 정리되지 않아요 Design Token구성이 제한되어 다른 타입/variant에 따라 차별화된 스타일링을 할 수 없어요- CSS 오버라이드는 인지 부하와 유지보수 비용이 높고, 유지보수성과 시맨틱이 좋지 않아요
이제 v6에서
토큰 확산과 수많은 API props 추가(유지보수 비용 증가)를 피하기 위해, 이 요소들을 더 시맨틱한 구조로 통합했어요.
- DOM 구조가 크게 단순화되고 정제됐어요.
- 다른 props에 기반해 스타일과 테마를 더 유연하고 유지보수 가능한 방식으로 커스터마이징할 수 있어요.
- 특정 시맨틱 영역에 대한 스타일이나 클래스 이름을 정의할 수 있어서, 로컬 스타일이나 테마 커스터마이징이 쉬워요.
const classNamesFn: ButtonProps['classNames'] = (
info,
): GetProp<ButtonProps, 'classNames', 'Return'> => {
if (info.props.type === 'primary') {
return { root: 'demo-btn-root--primary' };
}
return { root: 'demo-btn-root--default' };
};
const styles: ButtonProps['styles'] = {
root: { borderWidth: 2, borderStyle: 'dashed' },
content: { fontStyle: 'italic' },
icon: { opacity: 0.85 },
};
return (
<Button styles={styles} classNames={classNamesFn}>
Button
</Button>
);
Tailwind CSS와 결합
더 흥미로운 점은 classNames 속성이 Tailwind CSS 같은 아토믹 CSS 프레임워크와 완벽하게 통합된다는 거예요. 이는 개발자에게 전례 없는 자유를 제공해요: antd 컴포넌트의 프리셋 동작과 시맨틱 구조를 누리면서, Tailwind의 유틸리티 클래스를 활용해 원하는 어떤 시각적 스타일도 빠르게 만들 수 있어요. 시맨틱 디자인 + Tailwind CSS, 컴포넌트 커스터마이징이 극도로 유연해져요.
return (
<Button
classNames={{
root: 'bg-black text-white border-none hover:bg-[#2e2e2e]',
icon: 'text-white/90',
}}
icon={<GiftOutlined />}
>
Ant Design
</Button>
);
컴포넌트의 섬세한 아름다움 발견하기
사용자는 선호하는 색 구성에 따라 다른 상태의 컴포넌트에 정제된 디자인을 줄 수 있어요. 상상력을 마음껏 발휘해서 페이지를 더 생동감 있고 표현력 있게 만들어 보세요. 사용 중 문제가 생기거나 더 좋은 아이디어가 있으면 피드백을 공유해 주세요—함께 Ant Design을 더 좋게 만들어 봐요.
demos.tsx
import React from 'react';
import { Button, Drawer, Flex, Modal, Switch } from 'antd';
import BreadcrumbPreview from '../../../components/breadcrumb/demo/style-class';
import InputPreview from '../../../components/input/demo/style-class';
const { _InternalPanelDoNotUseOrYouWillBeFired: InternalPanel } = Modal;
const { _InternalPanelDoNotUseOrYouWillBeFired: InternalDrawer } = Drawer;
const SwitchNode = (
<Flex orientation="horizontal" gap="middle">
<Switch styles={{ root: { width: 40, backgroundColor: '#F5D2D2' } }} />
<Switch styles={{ root: { width: 40, backgroundColor: '#BDE3C3' } }} />
</Flex>
);
const ModalNode = (
<InternalPanel
footer={
<>
<Button
styles={{ root: { borderColor: '#ccc', color: '#171717', backgroundColor: '#fff' } }}
>
Cancel
</Button>
<Button
type="primary"
styles={{
root: { backgroundColor: '#171717', boxShadow: '0 2px 0 rgba(23,23,23,0.31)' },
}}
>
Submit
</Button>
</>
}
title="Custom Function Modal"
styles={{
container: { borderRadius: 14, border: '1px solid #ccc', padding: 0, overflow: 'hidden' },
header: { padding: 16, margin: 0 },
body: { padding: '0 16px' },
footer: { padding: 10, backgroundColor: 'rgba(250,250,250, 0.8)' },
}}
>
<div>🌈 Following the Ant Design specification.</div>
</InternalPanel>
);
const DrawerNode = (
<InternalDrawer
title="Drawer"
style={{ height: '100%', borderRadius: '10px 0 0 10px', overflow: 'hidden' }}
styles={{
header: { padding: 16 },
body: { padding: 16 },
footer: { padding: '16px 10px', backgroundColor: 'rgba(250,250,250, 0.8)' },
}}
footer={
<Flex gap="middle" justify="flex-end">
<Button
styles={{ root: { borderColor: '#ccc', color: '#171717', backgroundColor: '#fff' } }}
>
Cancel
</Button>
<Button
type="primary"
styles={{
root: { backgroundColor: '#171717', boxShadow: '0 2px 0 rgba(23,23,23,0.31)' },
}}
>
Submit
</Button>
</Flex>
}
>
<div>
🌈 Following the Ant Design specification, we developed a React UI library antd, interactive
user interfaces.
</div>
</InternalDrawer>
);
const h1Style: React.CSSProperties = {
fontSize: 20,
lineHeight: 2,
fontWeight: 'bold',
};
const Demo: React.FC = () => {
return (
<Flex orientation="horizontal" gap="middle" style={{ padding: 10 }}>
<div style={{ width: '35%' }}>
<h1 style={h1Style}>Input</h1>
<InputPreview />
</div>
<div style={{ width: '35%' }}>
<h1 style={h1Style}>Switch</h1>
{SwitchNode}
<h1 style={h1Style}>Breadcrumb</h1>
<BreadcrumbPreview />
<h1 style={h1Style}>Modal</h1>
{ModalNode}
</div>
<div style={{ width: '30%' }}>{DrawerNode}</div>
</Flex>
);
};
export default Demo;
토큰과 시맨틱 스타일링의 관계
Ant Design 디자인 시스템에서 토큰은 디자인 변수—디자인 언어의 원자적 재료—로 자리 잡아요. 반면 시맨틱 스타일은 그 재료를 어떻게 사용할지를 정의해요. 이는 디자인 토큰과 컴포넌트 레벨 커스터마이징을 결합해 만들어져, 더 유연하고 표현력 있는 스타일링 시나리오를 가능하게 해요. 시맨틱 스타일은 컴포넌트 레벨에서 작동하므로 스타일링 범위를 더 잘 제어할 수 있어요. 완전히 커스터마이징된 Ant Design 테마를 설계하는 게 목표라면, 토큰과 시맨틱 스타일링의 결합이 가장 강력한 도구가 될 거예요—이 둘을 함께 쓰면 더 정제되고 정밀하게 맞춤화된 테마를 만들 수 있어요.