5.28.0 • Published 3d ago
@cleartrip/ct-design-typography
Licence
ISC
Version
5.28.0
Deps
9
Size
305 kB
Vulns
0
Weekly
0
Typography
Typography component provides consistent text styling across the design system with predefined variants and color schemes.
Installation
npm install @cleartrip/ct-design-typography
# or
pnpm add @cleartrip/ct-design-typography
Peer dependencies
# Required for all targets
npm install react
# Web only
npm install react-dom
# React Native only
npm install react-native
Usage
Basic
import { Typography, TypographyVariant, TypographyColor } from '@cleartrip/ct-design-typography';
function Example() {
return (
<Typography variant={TypographyVariant.B1} color={TypographyColor.PRIMARY}>
This is sample typography text
</Typography>
);
}
Headings
<Typography variant={TypographyVariant.HD1} color={TypographyColor.HEADING}>
Large Display Heading
</Typography>
<Typography variant={TypographyVariant.HM1} color={TypographyColor.HEADING}>
Medium Heading
</Typography>
Body text
<Typography variant={TypographyVariant.B1} color={TypographyColor.PRIMARY}>
Large body text for important content
</Typography>
<Typography variant={TypographyVariant.B2} color={TypographyColor.SECONDARY}>
Regular body text with secondary color
</Typography>
Custom styling
<Typography
variant={TypographyVariant.B1}
color={TypographyColor.PRIMARY}
styleConfig={{
text: [{ fontWeight: 'bold', textDecoration: 'underline' }],
}}
>
Custom styled text
</Typography>
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
children |
ReactNode |
— | Yes | The content to be displayed within the typography element. |
variant |
TypographyVariantType |
— | Yes | The variant of the typography, such as 'h1', 'body1', etc. |
color |
TypographyColorType |
— | No | The color of the typography. |
isUnderlined |
boolean |
— | No | If true, adds an underline effect to the typography. |
isStriked |
boolean |
— | No | If true, adds a strikethrough effect to the typography. |
isClickable |
boolean |
— | No | If true, makes the typography clickable. |
onClick |
() => void |
— | No | Callback function triggered on typography click. |
colorCode |
string |
— | No | Color code to override the default color. |
showInItalics |
boolean |
— | No | If true, renders the typography in italics. |
width |
string |
— | No | The width of the typography element. |
lineClamp |
number |
— | No | The number of lines to clamp the text. Ellipsis (...) is added for overflow. |
isDisabled |
boolean |
— | No | If true, disables the typography for user interaction. |
componentNode |
TypographyNodeElementType |
— | No | The type of HTML element to be used for rendering the typography. |
styleConfig |
TypographyStyleConfigProps |
— | No | Style configuration for the typography. |
Variants
Display (HD)
HD1— Extra large display textHD2— Large display textHD3— Medium display text
Headings (HM)
HM1— Large headingHM2— Medium headingHM3— Small headingHM4— Extra small heading
Body (B)
B1— Large body textB2— Regular body textB3— Small body textB3CAPS— Small caps textB4— Extra small body textB4CAPS— Extra small caps text
Paragraphs (P)
P1— Large paragraphP2— Medium paragraphP3— Small paragraph
Labels (L)
L1— Large labelL2— Medium labelL3— Small label
Special
OVERLINE— Overline textTAG— Tag textM4BOLD— Bold variant
Colors
PRIMARY— Primary text colorSECONDARY— Secondary text colorTERTIARY— Tertiary text colorHEADING— Heading colorSUBHEADING— Subheading colorSUCCESS— Success state colorALERT— Alert/error state colorWARNING— Warning state colorDISABLED— Disabled state colorLINK— Link colorNEUTRAL— Neutral colorBRAND— Brand color
Migration
If migrating from previous versions:
- import { Typography } from 'yagami/core/components';
+ import { Typography, TypographyVariant, TypographyColor } from '@cleartrip/ct-design-typography';