@neo4j-ndl/react
Version:
React implementation of Neo4j Design System
73 lines (52 loc) • 1.86 kB
Markdown
Import: `import { Typography } from '@neo4j-ndl/react'`
| Prop | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `as` | `ElementType<any, keyof IntrinsicElements>` | | | An override of the default HTML tag of the root of the component. Can also be another React component. |
| `children` | `ReactNode` | | | Content displayed inside the component |
| `ref` | `any` | | | A ref to apply to the root element. |
| `variant` | `'body-large' \| 'body-medium' \| 'body-small' \| 'code' \| 'display' \| 'label' \| 'subheading-large' \| 'subheading-medium' \| 'subheading-small' \| 'title-1' \| 'title-2' \| 'title-3' \| 'title-4'` | ✅ | | The typography variant to use for the text. |
```tsx
import { Typography } from '../Typography';
const Component = () => (
<Typography variant="body-medium">
The quick brown fox jumps over the lazy dog.
</Typography>
);
export default Component;
```
```tsx
import { Typography } from '../Typography';
const Component = () => {
const variant = 'title-1';
return (
<Typography as="a" htmlAttributes={{ href: '/index' }} variant={variant}>
{variant}: The quick brown fox jumps over the lazy dog
</Typography>
);
};
export default Component;
```
```tsx
import { tokens } from '@neo4j-ndl/base';
import { Typography } from '../Typography';
const VARIANTS = Object.keys(tokens.typography) as Array<
keyof typeof tokens.typography
>;
const Component = () => (
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
{VARIANTS.map((variant) => (
<Typography key={variant} variant={variant}>
{variant}: The quick brown fox jumps over the lazy dog.
</Typography>
))}
</div>
);
export default Component;
```