The Typography component provides a flexible text rendering system with multiple variants. It's designed for headings, paragraphs, and any text content that needs consistent styling and formatting.
import { Typography } from '@dashflowx/core'export default function TypographyExample() {return (<Typography variant="para">Sample typography text</Typography>)}
Preview:
Sample typography text
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | '' | Additional CSS classes |
variant | string | 'para' | Typography variant |
disabled | boolean | false | Whether the typography is disabled |
fullwidth | boolean | false | Whether the typography takes full width |
lable | string | 'Typography' | Label for the typography |
required | boolean | false | Whether the field is required |
prefixElement | JSX.Element | - | Element to display before the typography |
sufixElement | JSX.Element | - | Element to display after the typography |
sucessMsg | string | - | Success message to display |
errorMsg | string | - | Error message to display |
| Variant | Description | Use Case |
|---|---|---|
one | Large heading (4xl) | Main page titles |
two | Large heading (3xl) | Section titles |
three | Medium heading (2xl) | Subsection titles |
four | Small heading (xl) | Card titles |
five | Large text (lg) | Important text |
six | Medium text (base) | Regular text |
para | Paragraph text (base) | Body text |
import { Typography } from '@dashflowx/core'export default function BasicTypography() {return (<Typography variant="para">Sample typography text</Typography>)}
Preview:
Sample typography text
import { Typography } from '@dashflowx/core'export default function CustomStyledTypography() {return (<Typographyvariant="para"className="border border-blue-500 rounded-lg p-4">Custom styled text</Typography>)}
Preview:
Sample typography text
import { Typography } from '@dashflowx/core'export default function TypographyWithLabel() {return (<Typographyvariant="para"lable="Text Content">Labeled typography text</Typography>)}
Preview:
Sample typography text
import { Typography } from '@dashflowx/core'export default function HeadingVariants() {return (<div><Typography variant="one">Heading One</Typography><Typography variant="two">Heading Two</Typography><Typography variant="three">Heading Three</Typography><Typography variant="four">Heading Four</Typography><Typography variant="five">Heading Five</Typography><Typography variant="six">Heading Six</Typography><Typography variant="para">Paragraph Text</Typography></div>)}
Preview:
Sample typography text
Sample typography text
Sample typography text
Sample typography text
Sample typography text
Sample typography text
Sample typography text
import { Typography } from '@dashflowx/core'export default function RequiredTypography() {return (<Typographyvariant="para"lable="Required text"required={true}>This text is required</Typography>)}
Preview:
Sample typography text
import { Typography } from '@dashflowx/core'export default function DisabledTypography() {return (<Typographyvariant="para"lable="Disabled text"disabled={true}>This text is disabled</Typography>)}
Preview:
Sample typography text
import { Typography } from '@dashflowx/core'export default function FullWidthTypography() {return (<Typographyvariant="para"lable="Full width text"fullwidth={true}>This text takes full width</Typography>)}
Preview:
Sample typography text
const pageTitle = (<Typography variant="one">Welcome to Our Platform</Typography>);
const sectionHeading = (<Typography variant="two">Features</Typography>);
const cardTitle = (<Typography variant="four">Product Name</Typography>);
const bodyText = (<Typography variant="para">This is the main content of your page.</Typography>);
const importantText = (<Typography variant="five">Important information</Typography>);
Use appropriate variants for different content types.
// ✅ Good - Appropriate variants<Typography variant="one">Page Title</Typography><Typography variant="para">Body text</Typography>// ❌ Avoid - Inappropriate variants<Typography variant="one">Body text</Typography><Typography variant="para">Page Title</Typography>
Maintain consistent styling across typography elements.
// ✅ Good - Consistent styling<Typography className="standard-typography-style" />// ❌ Avoid - Inconsistent styling<Typography className="random-styles" />
Ensure typography is accessible to all users.
// ✅ Good - Accessible text<Typography variant="para">Clear and readable text content</Typography>// ❌ Avoid - Not accessible<Typography variant="para">Text with poor contrast</Typography>
Use appropriate sizes for different contexts.
// ✅ Good - Appropriate sizing<Typography variant="one">Main title</Typography><Typography variant="para">Body text</Typography>// ❌ Avoid - Inappropriate sizing<Typography variant="one">Small text</Typography><Typography variant="para">Large title</Typography>
Use clear and descriptive labels when needed.
// ✅ Good - Clear labels<Typography lable="Article content" />// ❌ Avoid - Unclear labels<Typography lable="Text" />
You can customize the typography appearance using CSS classes:
<Typographyvariant="para"className="border border-gray-300 rounded-lg p-4"/>
Use different themes for different contexts:
// Light theme<Typography className="bg-white text-gray-900" />// Dark theme<Typography className="bg-gray-900 text-white" />// Brand theme<Typography className="bg-blue-50 text-blue-900" />
Use different sizes for different emphasis levels:
// Small text<Typography variant="six" className="text-sm" />// Standard text<Typography variant="para" className="text-base" />// Large text<Typography variant="five" className="text-lg" />
Load typography content dynamically:
const [content, setContent] = useState('');useEffect(() => {// Load content from APIloadContent().then(setContent);}, []);
Add validation to typography content:
const [hasError, setHasError] = useState(false);<Typographylable="Required content"required={true}errorMsg={hasError ? "Content is required" : ""}/>
Show success messages for typography content:
const [showSuccess, setShowSuccess] = useState(false);<Typographylable="Content saved"sucessMsg={showSuccess ? "Content saved successfully" : ""}/>
- H1-H6: For heading components
- P: For paragraph components
- Text: For text components
- Label: For form labels
- Button: For text buttons
For the complete API reference and advanced usage patterns, see the Typography API documentation.
