Dropdown
v0.0.10
mix mishka.ui.gen.component dropdown
Overview of the Phoenix LiveView dropdown Component
The Mishka Chelekom dropdown component is a highly customizable Phoenix LiveView tool for creating interactive and responsive dropdown menus. Ideal for navigation, action selection, and content display, it supports various styles, positions, and triggers with flexible options for colors, sizes, and border styles to seamlessly integrate into your app's design.
Overview of the Phoenix LiveView dropdown Component
This Phoenix LiveView component also includes customizable triggers for hover or click activation, as well as multiple content options, making it a versatile solution for enhancing user interaction and navigation within your application.
How to use dropdown
The dropdown is a wrapper that includes a trigger slot, which can be any button or the Mishka button component, and a content slot. You can add any list for navigation or other purposes in the content.
Dropdown color variant props
The dropdown component supports four distinct variants: default, outline, bordered, gradient, and shadow. Each variant can be styled with a variety of colors, including natural, primary, secondary, success, warning, danger, info, silver, misc, and dawn. These combinations allow for extensive customization to suit the design needs of your application.
Dropdown color variant props
<!--Base is the default variant and natural is the default color-->
<.dropdown id="dropdown-base"></.dropdown>
<.dropdown id="dropdown-default-natural" variant="default" color="natural"></.dropdown>
<.dropdown id="dropdown-default-white" variant="default" color="white"></.dropdown>
<.dropdown id="dropdown-default-dark" variant="default" color="dark"></.dropdown>
<.dropdown id="dropdown-default-primary" variant="default" color="primary"></.dropdown>
<.dropdown id="dropdown-shadow-secondary" variant="shadow" color="secondary"></.dropdown>
<.dropdown id="dropdown-shadow-dark" variant="shadow" color="dark"></.dropdown>
<.dropdown id="dropdown-bordered-success" variant="bordered" color="success"></.dropdown>
<.dropdown id="dropdown-bordered-warning" variant="bordered" color="warning"></.dropdown>
<.dropdown id="dropdown-outline-danger" variant="outline" color="danger"></.dropdown>
<.dropdown id="dropdown-outline-info" variant="outline" color="info"></.dropdown>
<.dropdown id="dropdown-default-silver" variant="default" color="silver"></.dropdown>
<.dropdown id="dropdown-shadow-misc" variant="shadow" color="misc"></.dropdown>
<.dropdown id="dropdown-bordered-dawn" variant="bordered" color="dawn"></.dropdown>Dropdown smart position
The smart_position attribute is a boolean property that dynamically adjusts the dropdown's position based on its visibility within the viewport. When set to true, it automatically detects if the dropdown would be cut off by the window edges and repositions it to ensure it remains fully visible. This is particularly useful for dropdowns near the bottom or edges of the screen, preventing content from being hidden or requiring user scrolling to access all options. For example, if a dropdown would extend beyond the bottom of the viewport, the smart positioning will automatically flip it to open upward instead. By default it's false.
Dropdown smart position
<.dropdown id="dropdown-smart-position-false" smart_position={false}></.dropdown>
<.dropdown id="dropdown-smart-position-true" smart_position={true}></.dropdown>Dropdown position prop
The dropdown component provides flexible positioning options through the position attribute. By default, the dropdown appears at the bottom, but it can be adjusted to other positions such as left, right, top, top-left, top-right, bottom-right, and bottom-left provide even more precise alignment, enhancing the layout flexibility in your application.
Dropdown position prop
<.dropdown id="dropdown-position-left" position="left"></.dropdown>
<.dropdown id="dropdown-position-right" position="right"></.dropdown>
<.dropdown id="dropdown-position-top" position="top"></.dropdown>
<.dropdown id="dropdown-position-top-left" position="top-left"></.dropdown>
<.dropdown id="dropdown-position-top-right" position="top-right"></.dropdown>
<.dropdown id="dropdown-position-bottom-left" position="bottom-left"></.dropdown>
<.dropdown id="dropdown-position-bottom-right" position="bottom-right"></.dropdown>Dropdown relative prop
The relative attribute in the dropdown component allows you to customize the relative positioning of the dropdown in relation to its trigger or parent element. By default, the dropdown takes no specific relative position, but using the relative attribute, you can set custom positioning for cases where the dropdown needs to adjust its placement dynamically within a specific context. This is particularly useful when the dropdown's position is dependent on its surrounding layout, such as within a scrolling container or when aligning it relative to other elements on the page. The flexibility of the relative attribute ensures that the dropdown can be tailored to fit seamlessly into various UI designs.
Dropdown relative prop
<.dropdown id="dropdown-relative" relative="relative">
<:trigger></:trigger>
<:content></:content>
</.dropdown>Dropdown clickable prop
The clickable attribute, when set to true, allows the dropdown to be activated by a click. by default is true
Dropdown clickable prop
<.dropdown relative="relative" clickable id="unique_id">
<:trigger></:trigger>
<:content></:content>
</.dropdown>Nomobile prop
The nomobile attribute is useful for fixing the position of nested dropdowns on mobile devices. When set to true, it adjusts the dropdown's positioning to ensure proper display in responsive layouts, particularly in complex navigation menus like a navbar. This prevents nested dropdowns from overlapping or displaying incorrectly on smaller screens, improving the overall usability and appearance of dropdowns in mobile views. this feature is only for mobile so you can see the influence of this prop in smaller screen sizes.
Nomobile prop
<!--This is exactly how to use this prop-->
<div class="relative">
<.dropdown id="dropdown-nomobile" relative="md:relative" space="small" rounded="large" width="large" padding="extra_small">
<:trigger>
<.button class="w-full">Dropdown</.button>
</:trigger>
<:content>
<ul class="space-y-5">
<li>
<.dropdown id="dropdown-nested" position="right" nomobile rounded="large" padding="extra_small">
<:trigger>
<button>Nested Dropdown</button>
</:trigger>
<:content>
<ul class="space-y-5">
<li>Security</li>
<li>Memory</li>
<li>Design</li>
</ul>
</:content>
</.dropdown>
</li>
<li>Tabs</li>
<li>Links</li>
</ul>
</:content>
</.dropdown>
</div>Width prop
The width attribute controls the dropdown's width, adjusting to fit the content by default. You can customize it to suit your layout needs, providing flexibility in how the dropdown fits within your design.
Width prop
<.dropdown id="dropdown-width-w-full" relative="relative" width="w-full"></.dropdown>
<.dropdown id="dropdown-width-w-1-2" relative="relative" width="w-1/2"></.dropdown>
<.dropdown id="dropdown-width-w-fit" relative="relative" width="w-fit"></.dropdown>Dropdown Rounded prop
The rounded prop offers values like extra_small, small, medium, large, and extra_large.
Dropdown Rounded prop
<.dropdown id="dropdown-rounded-extra-small" relative="relative" rounded="extra_small"></.dropdown>
<.dropdown id="dropdown-rounded-small" relative="relative" rounded="small"></.dropdown>
<.dropdown id="dropdown-rounded-medium" relative="relative" rounded="medium"></.dropdown>
<.dropdown id="dropdown-rounded-large" relative="relative" rounded="large"></.dropdown>
<.dropdown id="dropdown-rounded-extra-large" relative="relative" rounded="extra_large"></.dropdown>Dropdown Space prop
The space prop offers values such as extra_small, small, medium, large, and extra_large. These values control the vertical spacing between elements within the dropdown contents.
Dropdown Space prop
<.dropdown id="dropdown-space-extra-small" relative="relative" space="extra_small"></.dropdown>
<.dropdown id="dropdown-space-small" relative="relative" space="small"></.dropdown>
<.dropdown id="dropdown-space-medium" relative="relative" space="medium"></.dropdown>
<.dropdown id="dropdown-space-large" relative="relative" space="large"></.dropdown>
<.dropdown id="dropdown-space-extra-large" relative="relative" space="extra_large"></.dropdown>Dropdown Border prop
The border prop offers values like extra_small, small, medium, large, and extra_large. These values control the border size of the dropdown contetn, allowing you to adjust the thickness to suit your design.
Dropdown Border prop
<.dropdown id="dropdown-border-extra-small" relative="relative" border="extra_small"></.dropdown>
<.dropdown id="dropdown-border-small" relative="relative" border="small"></.dropdown>
<.dropdown id="dropdown-border-medium" relative="relative" border="medium"></.dropdown>
<.dropdown id="dropdown-border-large" relative="relative" border="large"></.dropdown>
<.dropdown id="dropdown-border-extra-large" relative="relative" border="extra_large"></.dropdown>Dropdown Padding prop
The padding prop offers values such as extra_small, small, medium, large, and extra_large. These values control the padding around the content inside the dropdown contents.
Dropdown Padding prop
<.dropdown id="dropdown-padding-extra-small" relative="relative" padding="extra_small"></.dropdown>
<.dropdown id="dropdown-padding-small" relative="relative" padding="small"></.dropdown>
<.dropdown id="dropdown-padding-medium" relative="relative" padding="medium"></.dropdown>
<.dropdown id="dropdown-padding-large" relative="relative" padding="large"></.dropdown>
<.dropdown id="dropdown-padding-extra-large" relative="relative" padding="extra_large"></.dropdown>Dropdown Width prop
The width attribute controls the width of the dropdown content. By setting the width value, you can easily limit how wide the dropdown can extend, maintaining a structured appearance across different screen sizes.
Dropdown Width prop
<.dropdown id="dropdown-width-extra-small" relative="relative" width="extra_small"></.dropdown>
<.dropdown id="dropdown-width-small" relative="relative" width="small"></.dropdown>
<.dropdown id="dropdown-width-medium" relative="relative" width="medium"></.dropdown>
<.dropdown id="dropdown-width-large" relative="relative" width="large"></.dropdown>
<.dropdown id="dropdown-width-extra-large" relative="relative" width="extra_large"></.dropdown>
<.dropdown id="dropdown-width-double-large" relative="relative" width="double_large"></.dropdown>
<.dropdown id="dropdown-width-triple-large" relative="relative" width="triple_large"></.dropdown>
<.dropdown id="dropdown-width-quadruple-large" relative="relative" width="quadruple_large"></.dropdown>
<.dropdown id="dropdown-width-full" relative="relative" width="full"></.dropdown>Dropdown size prop
The size prop offers values such as extra_small, small, medium, large, and extra_large. These values control text size within the dropdown contents.
Dropdown size prop
<.dropdown id="dropdown-size-extra-small" relative="relative" size="extra_small"></.dropdown>
<.dropdown id="dropdown-size-small" relative="relative" size="small"></.dropdown>
<.dropdown id="dropdown-size-medium" relative="relative" size="medium"></.dropdown>
<.dropdown id="dropdown-size-large" relative="relative" size="large"></.dropdown>
<.dropdown id="dropdown-size-extra-large" relative="relative" size="extra_large"></.dropdown>Dropdown font weight prop
The font_weight prop controls the font weight of the text. By setting this prop, you can determine how bold or light the text appears within the title section. The default value is font-normal. You can customize this value to apply different font weights, such as making the text lighter or bolder, depending on the visual style and emphasis you want to create for the dropdown. This provides flexibility in ensuring the title stands out appropriately within the overall dropdown layout.
Dropdown font weight prop
<.dropdown id="dropdown-font-weight-bold" relative="relative" font_weight="font-bold"></.dropdown>
<.dropdown id="dropdown-font-weight-thin" relative="relative" font_weight="font-thin"></.dropdown>Attributes
| Name | Type | Default | Values | Required | Description |
|---|---|---|---|---|---|
id
|
string
| — | — | Yes | A unique identifier is used to manage state and interaction |
class
|
any
| — | — | No | Custom CSS class for additional styling |
width
|
string
|
w-fit
| — | No | Determines the element width |
position
|
string
|
bottom
| — | No | Determines the element position |
relative
|
string
| — | — | No | Custom relative position for the dropdown |
clickable
|
boolean
|
true
| — | No | Determines if the element can be activated on click |
smart_position
|
boolean
|
false
| — | No | Enables and disables smart position |
nomobile
|
boolean
|
false
| — | No | Controls whether the dropdown is disabled on mobile devices |
variant
|
string
|
base
|
defaultoutlineborderedshadowgradientbase
| No | Determines the style |
color
|
string
|
natural
|
basenaturalwhitedarkprimarysecondarysuccesswarningdangerinfosilvermiscdawn
| No | Determines color theme |
rounded
|
string
| — |
extra_smallsmallmediumlargeextra_largenone
| No | Determines the border radius |
size
|
string
| — |
extra_smallsmallmediumlargeextra_large
| No | Determines the overall size of the elements, including padding, font size, and other items |
space
|
string
| — |
extra_smallsmallmediumlargeextra_large
| No | Space between items |
font_weight
|
string
|
font-normal
| — | No | Determines custom class for the font weight |
padding
|
string
|
none
|
extra_smallsmallmediumlargeextra_largenone
| No | Determines padding for items |
border
|
string
|
extra_small
| — | No | Determines border style |
rest
|
global
| — | — | No | Global attributes can define defaults which are merged with attributes provided by the caller |
Slots
| Name | Required | Description |
|---|---|---|
inner_block
| No | Inner block that renders HEEx content |
trigger
| No | — |
content
| No | — |
Attributes of the trigger slot
| Name | Type | Default | Values | Required | Description |
|---|---|---|---|---|---|
class
|
any
| — | — | No | Custom CSS class for additional styling |
Attributes of the content slot
| Name | Type | Default | Values | Required | Description |
|---|---|---|---|---|---|
class
|
any
| — | — | No | Custom CSS class for additional styling |
Options
Each option takes one or more of its values, separated by commas.
| Option | Values |
|---|---|
--variant
|
defaultoutlineborderedshadowgradientbase
|
--color
|
basenaturalwhitedarkprimarysecondarysuccesswarningdangerinfosilvermiscdawn
|
--size
|
extra_smallsmallmediumlargeextra_large
|
--space
|
extra_smallsmallmediumlargeextra_large
|
--rounded
|
extra_smallsmallmediumlargeextra_largenone
|
--padding
|
extra_smallsmallmediumlargeextra_largenone
|
--type
|
dropdowndropdown_triggerdropdown_content
|
--module
| A module name of your own |
What it generates
mix mishka.ui.gen.component dropdown