Skip to content

2.1

Responsive Design

Pixel Vue 3 support responsive design by using css() utility function that lets you write clean, responsive, and type-safe styles directly in your code. Pixel Vue 3 comes with 4 predefined breakpoints:

BreakpointMin Width (em)Min Width (px)Description
baseDefault (applies to all screen sizes)
sm22.5em360pxSmall screens (e.g., phones)
md48em768pxMedium screens (e.g., tablets)
lg64em1024pxLarge screens (e.g., laptops)
xl80em1280pxExtra-large screens (e.g., desktops)

ℹ️ base acts as the default style, used before any breakpoint overrides apply.

Example: Responsive backgroundColor

tsx
<script setup lang="ts">
  import {css } from '@mekari/pixel3'
</script>

<template>
  <div
    :class="css({
      backgroundColor: {
        base: 'orange.500', // default
        sm: 'lime.100',     // ≥ 22.5em
        md: 'fuchsia.100',  // ≥ 48em
        lg: 'leaf.100',     // ≥ 64em
        xl: 'dark'          // ≥ 80em
      }
    })"
  >
    Text
  </div>
</template>

Result Overview

Screen WidthBackground Color
< 22.5emorange.500
≥ 22.5emlime.100
≥ 48emfuchsia.100
≥ 64emleaf.100
≥ 80emdark

Simplify With Array Syntax

Pixel Vue 3 also accepts arrays as value.

tsx
<script setup lang="ts">
  import {css } from '@mekari/pixel3'
</script>

<template>
  <div
  :class="css({
    backgroundColor: [
      'orange.500',
      'lime.100',
      'fuchsia.100',
      'leaf.100',
      'dark']
  })">
  Text
</div>
</template>