Skip to content

Ring Width, Color, and Offset

View raw .md

Utilities for drawing an outline ring around an element. These are useful for focus states or highlighting elements without affecting layout.

On this page
Preview effects/ring_basic The live demo is not available for this example. ring_basic.dart View source
dart
// Default ring (3px blue-500)
WDiv(className: 'ring')

// Custom width and color
WDiv(className: 'ring-4 ring-red-500')

// With offset
WDiv(className: 'ring-2 ring-offset-2')

Basic Usage#

Use ring-{width} utilities to draw a solid outline around an element. By default, this adds a 3px blue ring.

dart
WDiv(
  className: 'ring-4 ring-blue-500 rounded-lg p-4',
  child: WText('Ring Example'),
)

Quick Reference#

Class Value Description
ring-0 0px No ring
ring-1 1px 1px ring width
ring-2 2px 2px ring width
ring 3px Default ring width (3px)
ring-4 4px 4px ring width
ring-8 8px 8px ring width
ring-inset - Forces ring to be on the inside
ring-offset-{width} - Moves the ring out, leaving an unpainted gap

Variants#

Ring Color#

Use ring-{color} to set the color of the ring. You can also use opacity modifiers like /50.

Preview effects/ring_colors The live demo is not available for this example. ring_colors.dart View source
dart
WDiv(className: 'ring-2 ring-blue-500')
WDiv(className: 'ring-2 ring-red-500/50') // 50% opacity

Ring Offset#

Use ring-offset-{width} to leave space between the element and the ring. The gap is not painted, so whatever is behind the element shows through it; Wind has no ring-offset-{color}.

dart
// Creates a 2px gap between the element and the ring
WDiv(className: 'ring-2 ring-offset-2')
Class Value Description
ring-offset-0 0px No offset
ring-offset-1 1px 1px offset
ring-offset-2 2px 2px offset
ring-offset-4 4px 4px offset
ring-offset-8 8px 8px offset

Ring Inset#

Use ring-inset to force the ring to render on the inside of the element instead of the outside. This is useful for elements that shouldn't overflow their container.

dart
WDiv(className: 'ring-2 ring-inset ring-pink-500')

Responsive Design#

Apply different ring utilities at different breakpoints using the standard sm:, md:, lg:, xl:, and 2xl: prefixes.

dart
WDiv(className: 'ring-2 md:ring-4 lg:ring-8')

Dark Mode#

Use the dark: prefix to apply different ring styles when the application is in dark mode.

dart
WDiv(className: 'ring-slate-900/5 dark:ring-white/10')

Arbitrary Values#

If the built-in scale doesn't meet your needs, use bracket notation to apply custom values directly.

dart
// Custom color
WDiv(className: 'ring-[#50d71e]')

// Custom color with opacity
WDiv(className: 'ring-[#50d71e]/50')

Customizing Theme#

To extend or override the default scale for rings, modify the WindThemeData in your app root.

dart
WindTheme(
  data: WindThemeData(
    // Default color when no ring color class is present
    ringColor: Colors.blue, 
    
    // Custom ring widths
    ringWidths: {
      'DEFAULT': 3,
      '6': 6,
      '10': 10,
    },
    
    // Custom offset widths
    ringOffsets: {
      '3': 3,
      '6': 6,
    },
  ),
  child: MyApp(),
)
esc

Search index did not load.

No match for "".

Try a class like rounded-lg or a widget like WButton.