Skip to content

Release 0.1.0 - Advanced Anchor Positioning & Fallbacks

Choose a tag to compare

@brandonmcconnell brandonmcconnell released this 04 May 10:33
· 114 commits to main since this release

This release introduces support for several advanced CSS Anchor Positioning properties, enabling conditional visibility, fallback strategies, and anchor-based alignment. It also includes an important fix for positional utilities.

✨ New Features

  • Anchor Center Utilities *-anchor[property]: anchor-center

    • Added utilities for centering elements relative to their anchor using anchor-center.
    • Includes:
      • justify-self-anchor (justify-self: anchor-center)
      • self-anchor (align-self: anchor-center)
      • justify-items-anchor (justify-items: anchor-center)
      • items-anchor (align-items: anchor-center)
      • place-items-anchor (place-items: anchor-center)
      • place-self-anchor (place-self: anchor-center)
  • Position Visibility anchored-visible-*position-visibility: [value]

    • Control element rendering based on anchor visibility or overflow state (position-visibility).
    • Keywords:
      • anchored-visible-always (position-visibility: always): Element is always visible.
      • anchored-visible-anchor (position-visibility: anchors-visible): Visible only when the anchor element is at least partially visible.
      • anchored-visible-no-overflow (position-visibility: no-overflow): Visible only when the element itself does not overflow the viewport.
    • Supports arbitrary values: anchored-visible-[value].
    • (Note: anchors-valid is part of the spec but not yet widely supported or included).
  • Position Try Order try-order-*position-try-order: [value]

    • Define the order in which fallback positions are attempted (position-try-order).
    • Keywords:
      • try-order-normal (position-try-order: normal): Default order.
      • try-order-w (position-try-order: most-width): Prioritize fallbacks maximizing width.
      • try-order-h (position-try-order: most-height): Prioritize fallbacks maximizing height.
    • Supports arbitrary values: try-order-[value].
  • Position Try Fallbacks try-*position-try-fallbacks: [value]:

    • Define a sequence of fallback positions or strategies (position-try-fallbacks).
    • Keywords:
      • try-none (position-try-fallbacks: none): No fallbacks.
      • try-flip-x (position-try-fallbacks: flip-inline): Flip horizontally.
      • try-flip-y (position-try-fallbacks: flip-block): Flip vertically.
      • try-flip-s (position-try-fallbacks: flip-start): Flip along the writing mode's start direction.
    • Supports standard position-area keywords (e.g., try-top applies position-try-fallbacks: top, try-bottom-left applies position-try-fallbacks: bottom left)
    • Supports arbitrary values: try-[value].

🐛 Bug Fixes

  • Positional Anchor Utilities: Fixed an issue where utilities like {top|right|bottom|left|inset}-anchor-{side}-{offset?} (e.g., top-anchor-bottom-4) were incorrectly configured. The offset value is now correctly optional, and the utilities properly map to the theme's inset scale values. Using top-anchor-bottom now correctly applies top: anchor(bottom) without requiring an explicit offset.