Phoenix UI

Phoenix UI home page
  1. Getting Started
  2. Installation: Tailwind CLI

Badge

Badge generates a small badge to the top-right of its child(ren).

Examples

Below you can view various demos with example markup.

Variants

The badge component supports dot and standard styling.

99+

Color

You can use the color attribute to define a color from theme palette.

99+
99+
99+
99+
99+
99+

Border

You can use the border attribute to add a light/dark-aware border.

99+

Position

The badge has 12 placements choices.

99+
99+
99+
99+

99+

99+
99+

99+

99+
99+
99+
99+

API

API documentation for the component. Learn about imports and available attributes.

Import

There are multiple ways to import components.


    # PhoenixUI macro which imports all components
    use PhoenixUI
    # Or import component individually
    import PhoenixUI.Components.Badge, only: [badge: 1]
    

Attributes

Below is a list of attributes that can be applied to the component.

Name Type Default Description
HTML attribute any Supports all HTML attributes.
border bool false If true, the badge will have a border.
color any tailwind color blue Any Tailwind-supported color.
extend_class string Adds additional classes.
invisible bool false If true, doesn't show the badge.
phx-{any} binding Supports all Phoenix DOM element bindings.
position "bottom_end" | "bottom_start" | "bottom" | "left_end" | "left_start" | "left" | "right_end" | "right_start" | "right" | "top_end" | "top_start" | "top" top_end The position to use.
variant "dot" | "standard" standard The variant to use.
wrapper any attribute Used to extend/override wrapper attributes