React 배지 개요
Ignite UI for React Badge는 시각적 알림이 필요할 때 아바타, 탐색 메뉴 또는 응용 프로그램의 기타 구성 요소와 함께 사용되는 구성 요소입니다. 배지는 일반적으로 정보, 성공, 경고 또는 오류를 전달하기 위해 미리 정의된 스타일로 디자인됩니다.
React 배지 예시
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrBadge, IgrBadgeModule } from "@infragistics/igniteui-react";
import 'igniteui-webcomponents/themes/light/bootstrap.css';
IgrBadgeModule.register();
export default class BadgeOutlined extends React.Component<any, any> {
constructor(props: any) {
super(props);
}
public render(): JSX.Element {
return (
<div className="sample">
<IgrBadge outlined={true} />
</div>
);
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<BadgeOutlined/>);
tsx
이 샘플이 마음에 드시나요? Ignite UI for React 전체에 액세스하고 몇 분 만에 나만의 앱을 빌드하기 시작하세요. 무료로 다운로드하세요.
용법
먼저, 다음 명령을 실행하여 Ignite UI for React 설치해야 합니다.
npm install igniteui-react
cmd
그런 다음 다음과 같이 필요한 CSS인 IgrBadge
가져오고 해당 모듈을 등록해야 합니다.
import { IgrBadgeModule, IgrBadge } from 'igniteui-react';
import 'igniteui-webcomponents/themes/light/bootstrap.css';
IgrBadgeModule.register();
tsx
<IgrBadge />
tsx
배지 주위에 미묘한 테두리를 표시하려면 배지의 outlined
속성을 설정하면 됩니다.
<IgrBadge outlined="true" ></IgrBadge>
tsx
예
변형
Ignite UI for React 배지는 사전 정의된 여러 스타일 변형을 지원합니다. 지원되는 값 중 하나를 할당하여 변형을 변경할 수 있습니다. primary
(기본값), info
, success
, warning
또는 danger
에 variant
속성.
<IgrBadge variant="success" ></IgrBadge>
tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrBadge, IgrBadgeModule } from "@infragistics/igniteui-react";
import 'igniteui-webcomponents/themes/light/bootstrap.css';
IgrBadgeModule.register();
export default class BadgeVariants extends React.Component<any, any> {
constructor(props: any) {
super(props);
}
public render(): JSX.Element {
return (
<div className="sample">
<IgrBadge variant="success" />
</div>
);
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<BadgeVariants/>);
tsx
모양
배지 구성 요소는 rounded
(기본값) 모양과 square
모양을 지원합니다. 이러한 값은 shape
속성에 할당될 수 있습니다.
<IgrBadge shape="square" ></IgrBadge>
tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrBadge, IgrBadgeModule } from "@infragistics/igniteui-react";
import 'igniteui-webcomponents/themes/light/bootstrap.css';
IgrBadgeModule.register();
export default class BadgeShape extends React.Component<any, any> {
constructor(props: any) {
super(props);
}
public render(): JSX.Element {
return (
<div className="sample">
<IgrBadge shape="square" />
</div>
);
}
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<BadgeShape/>);
tsx
스타일링
구성 요소는 IgrBadge
모든 스타일 속성을 변경하는 데 사용할 수 있는 CSS 파트를 노출 base
합니다.
igc-badge::part(base) {
background: var(--ig-primary-500);
color: var(--ig-primary-500-contrast);
border-radius: 2px;
}
css
API 참조
추가 리소스