Components
DataCard
A comprehensive showcase component demonstrating mks-ui patterns including glassmorphism, slot overrides, animated counters, and state-based styling.
DataCard
The DataCard is the flagship showcase component that demonstrates the full range of @mks2508/mks-ui patterns — slot overrides, state-based styling, CVA variants, motion animations, form integration, and glassmorphism effects.
Import
import {
DataCard,
DataCardValue,
DataCardLabel,
DataCardToggle,
DataCardActions,
} from '@mks2508/mks-ui/react';Features Demonstrated
- Slot overrides — Customize any visual region via
slotsprop - State-based styling — Reactive styles for hover, pressed, disabled states
- CVA variants — Size and color variant combinations
- asChild composition — Compose with other elements using Slot pattern
- Motion/animation — Spring-based number counter animations via CountingNumber
- Custom render functions — Both
classNameandstyleas functions of state - Form field integration — Controlled Switch/toggle components
- Icon composition — Flexible slot support for icons
- Glassmorphism — Synthwave Dark theme effects with backdrop blur
- Corner brackets — Industrial-style corner decorations (auto-rendered)
Basic Usage
Basic Usage
.tsx
<DataCard>
<DataCardLabel title="Total Users" description="Active sessions" />
<DataCardValue number={1234} />
</DataCard>Variants
Variants
Size Variants
Sizes
With Toggle
With Toggle
.tsx
<DataCard variant="accent">
<DataCardLabel title="Live Updates" description="Real-time sync" />
<DataCardValue number={256} unit="users" />
<DataCardToggle checked={true} label="Enabled" />
</DataCard>Slot Overrides
Customize any visual region using the slots prop:
<DataCard
slots={{
root: 'border-cyan-400/50 shadow-cyan-500/30',
bracket: 'opacity-80',
value: 'text-cyan-300',
toggle: 'justify-center',
}}
variant="accent"
>
<DataCardValue number={999} />
<DataCardToggle checked={true} />
</DataCard>State-Based Styling
Pass functions for className or style to react to interaction state:
<DataCard
className={(state) =>
state.hovered ? 'scale-105 shadow-2xl' : 'scale-100'
}
style={(state) => ({
transform: state.pressed ? 'scale(0.98)' : 'scale(1)',
})}
>
<DataCardValue number={1234} />
</DataCard>State Object
| Property | Type | Description |
|---|---|---|
hovered | boolean | Mouse is over the card |
pressed | boolean | Card is being pressed |
disabled | boolean | Card is disabled |
Configuration
<DataCard
config={{
animateBrackets: true,
counterStiffness: 200,
counterDamping: 20,
}}
>
<DataCardValue number={42} />
</DataCard>API Reference
DataCard
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'default' | 'accent' | 'success' | 'warning' | 'destructive' | 'default' | Color variant |
size | 'compact' | 'default' | 'spacious' | 'default' | Size preset |
disabled | boolean | false | Disable interactions |
glass | boolean | true | Enable glassmorphism effect |
showBrackets | boolean | true | Show corner bracket decorations |
className | string | ((state: IDataCardState) => string) | — | Static or state-based classes |
style | CSSProperties | ((state: IDataCardState) => CSSProperties) | — | Static or state-based styles |
slots | SlotOverrides<DataCardSlot> | — | Style overrides per slot |
config | IDataCardConfig | — | Animation configuration |
DataCardValue
| Prop | Type | Default | Description |
|---|---|---|---|
number | number | — | Animated target value |
label | string | — | Prefix label (e.g., "$") |
unit | string | — | Suffix unit (e.g., "%", "/sec") |
decimalPlaces | number | 0 | Decimal precision |
padStart | boolean | false | Pad with leading zeros |
DataCardLabel
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | — | Primary label text |
description | string | — | Secondary description |
DataCardToggle
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | — | Controlled checked state |
onCheckedChange | (checked: boolean) => void | — | Change handler |
label | string | — | Toggle label text |
checkedIcon | ReactNode | — | Icon when checked |
uncheckedIcon | ReactNode | — | Icon when unchecked |
DataCardActions
| Prop | Type | Default | Description |
|---|---|---|---|
align | 'start' | 'center' | 'end' | 'end' | Action alignment |
Slots
| Slot | Description |
|---|---|
root | Outer card container |
bracket | Corner bracket decorations |
header | Header region |
value | Number display area |
label | Label text area |
toggle | Toggle switch region |
actions | Action buttons container |
footer | Footer region |