Expand description
§Freyr UI Components Library for Dioxus.
This crate provides a set of customizable UI components for use in Dioxus projects. It allows developers to easily integrate and style components such as navbars, carousels and buttons, with flexible configuration options for color schemes and layouts. Just make it your own!
§Why the name Freyr?
Freyr is the norse god of fertility and prosperity and is known for his beauty. Your Dioxus web app should also look good.
§Warning:
This component is in the early stage of development. Right now there are only five components available: the navbar, the dropdown, the two carousel and the buttons. New components will be added, and some features that already exist may change. Freyr was created out of fun to help me reuse the components I had already used in other project, while I was learning Rust and Dioxus. So I also hope it’s going to help you too.
§Features
- Buttons
- Tabs
- Navbar
- Accordion
- Carousel
- Dropdown
- Dialog
- Spinner
All those components have more features than you think. For more information about them please chack them here.
§Key Features
- Full customization of colors, sizes, and layouts using configuration structs and enums.
- Easy integration into Dioxus web projects.
§Example Usage
#![allow(non_snake_case)]
use dioxus::prelude::*;
use freyr::prelude::*;
#[derive(Clone, Routable, Debug, PartialEq)]
enum Route {
#[layout(Navigation)]
#[route("/")]
Home {},
}
#[component]
fn Navigation() -> Element {
let navbar_config = NavbarConfig {
background_color: ColorScheme::Dark,
nav_header: Some(String::from("Freyr")),
orientation: Some(Orientation::Center),
header_color: HeaderColor::Light,
nav_items: vec!["Home".to_string(), "About".to_string(), "Contact".to_string()],
nav_links: vec!["/".to_string(), "/about".to_string(), "/contact".to_string()],
nav_item_color: NavItemsColor::Custom("#990000"),
icon_color: IconColor::Custom("#99cc00"), // Sets the color for both the hamburger SVG and the cross SVG.
};
rsx! {
Navbar { navbar_config }
Outlet::<Route> {}
}
}
#[component]
fn Home() -> Element {
rsx! {
div {
BasicButton { color: ButtonColor::Freyr, label: String::from("Go Home"), link: ButtonUrl { url: "/".to_string() } }
BasicButton { color: ButtonColor::Primary, label: String::from("Go to About"), link: ButtonUrl { url: "/about".to_string() } }
// Here the routing is made optional
BasicButton { color: ButtonColor::Freyr, label: String::from("Hello") }
}
}
}
#[component]
fn Dropdown() -> Element {
let dropdown_items = vec![
DropdownItem { label: String::from("Freyr"), url: String::from("/") },
DropdownItem { label: "See freyr's components".to_string(), url: "/components".to_string() },
DropdownItem { label: "Learn about dioxus".to_string(), url: "/learn-dioxus".to_string() },
];
let config_dropdown = DropdownConfig {
title: String::from("Menu"),
label: dropdown_items,
background_color: DropdownColorScheme::Freyr,
title_color: DropdownTitleColor::Light,
labels_color: DropdownLabelsColor::Dark,
hover_color: DropdownHoverColor::Custom("#03346E"),
};
rsx! {
div {
DropdownMenu { config_dropdown }
}
}
}
For more documentation about the actual components, please go to the functions.
Re-exports§
pub use BasicButton_completions::Component::BasicButton;
pub use CarouselSimple_completions::Component::CarouselSimple;
pub use CarouselWithTimer_completions::Component::CarouselWithTimer;
pub use CarouselWithNumbers_completions::Component::CarouselWithNumbers;
pub use DropdownMenu_completions::Component::DropdownMenu;
pub use DropdownMenuButton_completions::Component::DropdownMenuButton;
Modules§
Structs§
- Accordion
Custom Props - Accordion
Left Props - The “title”, “icon_color”, and “children” properties are mandatory, but all the other ones are optional propreties.
- Accordion
Props - Props are:
title
,accordion_text
,optional_text
,icon_color
,class
,title_class
,accordion_wrapper
,accordion_content
- Basic
Button Props - Properties for the
BasicButton
component. - Button
Props - Button
Url - Carousel
Item - Carousel
Simple Props - Properties for the
CarouselSimple
component. - Carousel
With Numbers Props - Properties for the
CarouselWithNumbers
component. - Carousel
With Timer Props - Properties for the
CarouselWithTimer
component. - Dialog
Props - Dialog
Without Button Props - Dropdown
Button Config - Dropdown
Config DropdownConfig
holds the configuration for the dropdown menu, including the list of dropdown items, background color, and text color.- Dropdown
Config NavBar - Represents a dropdown configuration with its label and items.
- Dropdown
Item DropdownItem
represents an individual item in the dropdown menu, containing a label and a URL for navigation.- Dropdown
Menu Button Props - Properties for the
DropdownMenuButton
component. - Dropdown
Menu Props - Properties for the
DropdownMenu
component. - Navbar
Config - Configuration struct for the
Navbar
component. - Navbar
Dropdown Buttons Props - Properties for the
NavbarDropdownButtons
component. - Navbar
Dropdown Config - Configuration struct for the
NavbarDropdown
component. - Navbar
Dropdown Props - Properties for the
NavbarDropdown
component. - Navbar
Props - Properties for the
Navbar
component. - Navbar
With Logo Config - Configuration struct for the
NavbarWithLogo
component. - Navbar
With Logo Props - Properties for the
NavbarWithLogo
component. - Tabs
Props - Tabs
Secondary Props
Enums§
- Accordion
Color - Accordion
Icon Color - Defines different color options for navigation items.
- Button
Color - Enum that defines which color you want to use for the button.
- Color
Scheme - Configuration options for the
Navbar
component, including color schemes and menu settings. Represents different background color schemes for the navbar. - Dropdown
Color Scheme - Represents different background color schemes for the dropdown.
- Dropdown
Hover Color - Defines different color options for dropdown background hover color.
- Dropdown
Labels Color - Defines different color options for dropdown labels.
- Dropdown
Title Color - Defines different color options for the title of the dropdown.
- Header
Color - Icon
Color - Specifies color options for the menu icons (hamburger and cross).
- NavItems
Color - Defines different color options for navigation items.
- Orientation
- Tabs
Color
Functions§
- Accordion
- Standard accordion usage example:
- Accordion
Custom - Accordion Custom content example:
- Accordion
Left - Accordion where the icon and title are placed on the left:
- Basic
Button - Defines which kind of button you want to use: Freyr, Primary, Success, Danger, Black or Transparent. You may also add a route.
- Carousel
Simple - A simple carousel component for Dioxus.
- Carousel
With Numbers - To be used like the CarouselSimple component.
- Carousel
With Timer - Use it like the CarouselSimple component, just add the
timer_seconds
prop like that:timer_seconds: 5
- Dialog
- Usage example of the
dialog
component: - Dialog
Without Button - This dialog is similar to the
Dialog
component but does not get a starting button to display it. Instead, you have to create your own button or whatever you want to activate it. - Dropdown
Menu DropdownMenu
is a customizable dropdown menu component. You can pass aDropdownConfig
to customize the list of items, background color, and text color.- Dropdown
Menu Button - Usage example of a dropdown that passes onclick events to its items like a dummy counter:
- Event
Button - Usage of the button with an event attached to it:
- Navbar
- You can configure background color, navigation items, and icon colors.
- Navbar
Dropdown - Navbar with a Dropdown menu implementation example:
- Navbar
Dropdown Buttons - Example use of the navbar with a dropdown menu that allows you to pass onclick events. This example introduces the use of dioxus-i18n for internationalization.
- Navbar
With Logo - This navbar works the same as the normal navbar component, but instead of taking a logo as String it takes an image.
- Spinner
- Usage example:
- Tabs
Primary - Tabs usage example:
- Tabs
Secondary - Code implementation: