Understand Before You Build

  • HTML
    • Form
    • HTML pattern Attribute
  • CSS
    • inset
    • scroll-snap-type
    • margin-inline
    • Content-visibility
    • Scroll-Driven Animations
    • Isolation
    • @Container
    • @layer
    • :not()
    • :is()
    • :Where()
    • :has()
    • :target
    • backdrop-filter
    • :root
    • Color-scheme
    • Animations
    • Selectors
    • Object-fit
    • Logical Pseudo-Classes
    • :scope
    • Properties
    • Performance
    • Aspect-ratio
    • State Pseudo-Classes
    • Positioning
    • Resize
    • Structural Pseudo-Classes
    • Responsive Design
    • Units
    • Root & Scope Selectors
    • Scrolling
    • At-Rules
    • Target & URL Selectors
    • Spacing
    • Functions
    • Attribute Selectors
    • Layouts
    • Basic Selectors
    • Filters & Effects
    • Colors & Typography
    • Flexbox
    • Combinator Selectors
    • Grid
    • Form & UI State Selectors
    • AI CSS Generator
  • Sass
    • Variables
    • Nesting
    • Mixins
    • Reusable styles
    • Large project management
  • CSS Frameworks
    • Material UI
    • Bootstrap
    • Tailwind CSS
  • React UI
    • Performance Optimization
    • React.memo
    • useMemo
    • useCallback
    • Lazy Loading
    • Code Splitting
    • Virtual DOM Optimization
    • Preventing Re-renders
    • Props & State
    • Hooks
    • Component-based architecture
    • State-driven UI updates
  • Figma
    • Design systems
    • Tokens
    • Variables
    • Auto layout
    • Component variants
    • Design handoff
    • UI consistency

Basics of Component variants

Component Variants

Component Variants are different versions or states of the same UI component.

Instead of creating separate components for every style, one reusable component supports multiple variations.


Simple Meaning

One button component can have:

  • Primary
  • Secondary
  • Outline
  • Danger
  • Disabled
  • Loading

These are called variants.


Why Variants Are Important?

  • Reusable UI
  • Consistent design
  • Cleaner frontend architecture
  • Less duplicate code
  • Easy maintenance
  • Scalable design systems

Without Variants

Developers may create multiple separate components.

[code theme="dark"] PrimaryButton SecondaryButton DangerButton [/code]

This becomes difficult to maintain.


With Variants

One reusable component handles everything.

[code theme="dark"] ); } [/code]

Using Variants

[code theme="dark"] [/code]

4. Theme Variants

Different themes.


Examples

[code theme="dark"] Light Dark Brand Themes [/code]

Figma Component Variants

Figma supports variants directly inside components.


Example

[code theme="dark"] Button Variant: Primary Secondary Outline [/code]

Figma Variant Example

Imagesss

Why Figma Variants Are Useful?

  • Reusable components
  • Easy design updates
  • Consistent UI
  • Developer-friendly handoff

Variant Properties

Variants can combine multiple properties.


Example

[code theme="dark"] Variant → Primary Size → Large State → Disabled [/code]

Result

One component supports many combinations.


Real Frontend Example

[code theme="dark"]