### Install Fresh Package Source: https://github.com/dreamrs/fresh/blob/master/README.md Installs the stable version of the 'fresh' package from CRAN or the development version from GitHub. ```r install.packages("fresh") ``` ```r remotes::install_github("dreamRs/fresh") ``` -------------------------------- ### Button Component Styling Example Source: https://context7.com/dreamrs/fresh/llms.txt This snippet provides an example of styling button components within a Shiny application using the `fresh` package. While the specific code for `bs_vars_button()` is not shown, this section title indicates its purpose: to customize the appearance of buttons, including their colors, borders, and sizes across different states. This requires the 'fresh' and 'shiny' R packages. -------------------------------- ### Create Custom Theme with bs4Dash - R Source: https://context7.com/dreamrs/fresh/llms.txt Demonstrates creating and applying a custom theme to a bs4Dash application using the fresh package. The example shows how to define primary and success colors through bs4Dash_theme() and apply them with use_theme(). This approach is suitable for branded corporate applications and rapid prototyping without CSS knowledge. ```r library(bs4Dash) ui_bs4 <- dashboardPage( header = dashboardHeader(title = "Dashboard"), sidebar = dashboardSidebar(), body = dashboardBody( use_theme(bs4Dash_theme( primary = "#007bff", success = "#28a745" )), box(title = "Content", status = "primary", "Dashboard content") ) ) # Run any UI server <- function(input, output, session) {} if (interactive()) shinyApp(ui_inline, server) ``` -------------------------------- ### Create Shiny Application Theme Source: https://github.com/dreamrs/fresh/blob/master/README.md Generates a custom CSS theme for Shiny applications using the `create_theme` function. This example customizes navbar colors, general link colors, and various other color variables including brand colors and state-specific colors. The output is saved to a CSS file. ```r create_theme( theme = "default", bs_vars_navbar( default_bg = "#3f2d54", default_color = "#FFFFFF", default_link_color = "#FFFFFF", default_link_active_color = "#FFFFFF" ), bs_vars_color( gray_base = "#354e5c", brand_primary = "#75b8d1", brand_success = "#c9d175", brand_info = "#758bd1", brand_warning = "#d1ab75", brand_danger = "#d175b8" ), bs_vars_state( success_text = "#FFF", success_bg = "#c9d175", success_border = "#c9d175", info_text = "#FFF", info_bg = "#3f2d54", info_border = "#3f2d54", danger_text = "#FFF", danger_bg = "#d175b8", danger_border = "#d175b8" ), bs_vars_wells( bg = "#FFF", border = "#3f2d54" ), output_file = "www/mytheme.css" ) ``` -------------------------------- ### Apply Global Dashboard Layout Settings Source: https://context7.com/dreamrs/fresh/llms.txt This R code demonstrates how to customize the global layout of a shinydashboard application using the 'fresh' package. It allows setting background colors for the dashboard content, boxes, and info boxes, as well as applying a specific color theme to the dashboard. The example applies custom background colors to boxes and info boxes, enhancing the visual consistency. ```r library(fresh) library(shinydashboard) ui <- dashboardPage( header = dashboardHeader(title = "Custom Layout"), sidebar = dashboardSidebar( sidebarMenu( menuItem("Home", tabName = "home", icon = icon("home")) ) ), body = dashboardBody( use_theme(create_theme( adminlte_global( content_bg = "#ECF0F1", box_bg = "#FFFFFF", info_box_bg = "#FFFFFF" ), adminlte_color( light_blue = "#3498DB" ) )), fluidRow( box( title = "Box 1", width = 6, status = "primary", "Content with custom background" ), box( title = "Box 2", width = 6, status = "info", "More content here" ) ), fluidRow( infoBox("Metric", 42, icon = icon("chart-line"), width = 4), infoBox("Status", "Active", icon = icon("check"), width = 4, color = "green"), infoBox("Users", 1234, icon = icon("users"), width = 4, color = "yellow") ) ) ) server <- function(input, output, session) {} if (interactive()) shinyApp(ui, server) ``` -------------------------------- ### Create Navbar with Custom Navigation Bar Styling Source: https://context7.com/dreamrs/fresh/llms.txt This example demonstrates how to style the navigation bar of a Shiny application using `fresh::bs_vars_navbar`. It allows customization of height, margins, padding, colors for the default state, active state, and hover states of navigation links. The `use_theme` function applies these customizations. Dependencies include 'fresh' and 'shiny'. ```r library(fresh) library(shiny) ui <- navbarPage( title = "My App", theme = NULL, header = use_theme(create_theme( theme = "default", bs_vars_navbar( height = "60px", margin_bottom = "20px", border_radius = "0px", padding_horizontal = "20px", padding_vertical = "15px", default_color = "#FFFFFF", default_bg = "#2C3E50", default_border = "#1A252F", default_link_color = "#ECF0F1", default_link_active_color = "#FFFFFF", default_link_active_bg = "#34495E", default_link_hover_color = "#3498DB", default_link_hover_bg = "#34495E" ) )), tabPanel("Home", h2("Home Page")), tabPanel("Analytics", h2("Analytics Dashboard")), tabPanel("Reports", h2("Reports Section")), navbarMenu("More", tabPanel("Settings", h2("Settings")), tabPanel("Help", h2("Help Center")) ) ) server <- function(input, output, session) {} if (interactive()) shinyApp(ui, server) ``` -------------------------------- ### Create Theme with Custom Typography Control Source: https://context7.com/dreamrs/fresh/llms.txt This example illustrates how to customize typography settings in a Shiny theme using `fresh::bs_vars_font` and `fresh::bs_vars_global`. It allows control over font families for sans-serif text and sets base font size, heading sizes, and line height for improved readability and visual hierarchy. Dependencies: 'fresh', 'shiny'. ```r library(fresh) library(shiny) ui <- fluidPage( use_theme(create_theme( theme = "default", bs_vars_font( family_sans_serif = "'Open Sans', 'Segoe UI', Roboto, sans-serif", size_base = "16px", size_large = "18px", size_small = "14px", size_h1 = "42px", size_h2 = "36px", size_h3 = "28px", size_h4 = "22px", size_h5 = "18px", size_h6 = "16px" ), bs_vars_global( line_height_base = "1.7" ) )), titlePanel("Typography Demo"), h1("Heading 1 - 42px"), h2("Heading 2 - 36px"), h3("Heading 3 - 28px"), h4("Heading 4 - 22px"), h5("Heading 5 - 18px"), h6("Heading 6 - 16px"), p("Base paragraph text at 16px with 1.7 line height for improved readability."), p(class = "text-small", tags$small("Small text at 14px")), p(class = "lead", "Large lead text at 18px for emphasis") ) server <- function(input, output, session) {} if (interactive()) shinyApp(ui, server) ``` -------------------------------- ### Customize shinydashboard Sidebar with Colors and Width Source: https://context7.com/dreamrs/fresh/llms.txt This R code snippet shows how to customize the appearance of a shinydashboard sidebar using the 'fresh' package. It allows setting the sidebar width, background colors for dark themes, hover effects, text colors, and submenu styling. The example includes a sidebar with multiple menu items and sub-items, demonstrating the application of custom styles. ```r library(fresh) library(shinydashboard) ui <- dashboardPage( header = dashboardHeader(title = "Navigation Demo"), sidebar = dashboardSidebar( sidebarMenu( menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Reports", icon = icon("bar-chart-o"), menuSubItem("Sales", tabName = "sales"), menuSubItem("Marketing", tabName = "marketing"), menuSubItem("Operations", tabName = "operations") ), menuItem("Settings", tabName = "settings", icon = icon("gear")) ) ), body = dashboardBody( use_theme(create_theme( adminlte_sidebar( width = "280px", dark_bg = "#2E3440", dark_hover_bg = "#4C566A", dark_color = "#ECEFF4", dark_hover_color = "#88C0D0", dark_submenu_bg = "#3B4252", dark_submenu_color = "#D8DEE9", dark_submenu_hover_color = "#8FBCBB" ) )), h2("Sidebar styling demo"), p("Hover over menu items to see custom hover effects") ) ) server <- function(input, output, session) {} if (interactive()) shinyApp(ui, server) ``` -------------------------------- ### Theme Application Methods - use_theme() Source: https://context7.com/dreamrs/fresh/llms.txt Shows two methods for applying themes: inline theme creation with output_file = NULL for returning CSS directly, and file-based approach where CSS is written to the www/ directory and referenced by filename. ```r library(fresh) library(shiny) # Method 1: Inline theme (no file created) ui_inline <- fluidPage( use_theme(create_theme( theme = "default", bs_vars_global( body_bg = "#1a1a1a", text_color = "#ffffff" ), bs_vars_wells( bg = "#2a2a2a" ), output_file = NULL # Return CSS instead of writing file )), h1("Dark Theme"), p("This theme is applied inline without creating a file") ) # Method 2: CSS file path (in www/ directory) create_theme( theme = "default", bs_vars_color(brand_primary = "#9C27B0"), output_file = "www/purple-theme.css" ) ui_file <- fluidPage( use_theme("purple-theme.css"), # Reference file in www/ h1("Purple Theme"), actionButton("btn", "Click", class = "btn-primary") ) ``` -------------------------------- ### Create Theme with Custom Global Settings Source: https://context7.com/dreamrs/fresh/llms.txt This snippet shows how to create a custom theme for a Shiny application using `fresh::create_theme`. It customizes global settings such as body background, text color, link colors, line height, grid dimensions, border radius, and font family/size. The `bs_vars_global` and `bs_vars_font` functions are used for these customizations. Dependencies include the 'fresh' and 'shiny' R packages. ```r library(fresh) library(shiny) ui <- fluidPage( use_theme(create_theme( theme = "default", bs_vars_global( body_bg = "#F5F5F5", text_color = "#2C3E50", link_color = "#3498DB", link_hover_color = "#2980B9", line_height_base = "1.6", grid_columns = 12, grid_gutter_width = "20px", border_radius_base = "6px" ), bs_vars_font( family_sans_serif = "'Roboto', 'Helvetica Neue', Arial, sans-serif", size_base = "16px" ) )), h1("Global Theme Demo"), fluidRow( column(4, wellPanel("Column 1")), column(4, wellPanel("Column 2")), column(4, wellPanel("Column 3")) ), p("This is a paragraph with custom line height and font."), a("This is a link", href = "#"), br(), br(), actionButton("btn", "Button with custom border radius") ) server <- function(input, output, session) {} if (interactive()) shinyApp(ui, server) ``` -------------------------------- ### Button Styling with Bootstrap Variables Source: https://context7.com/dreamrs/fresh/llms.txt Demonstrates comprehensive button customization using bs_vars_button() to define font weights, border radius, colors, and background for different button states including default, primary, success, and danger variants. ```r library(fresh) library(shiny) ui <- fluidPage( use_theme(create_theme( theme = "default", bs_vars_button( font_weight = "600", border_radius_base = "4px", border_radius_large = "6px", border_radius_small = "3px", default_color = "#2C3E50", default_bg = "#ECF0F1", default_border = "#BDC3C7", primary_color = "#FFFFFF", primary_bg = "#3498DB", primary_border = "#2980B9", success_color = "#FFFFFF", success_bg = "#2ECC71", success_border = "#27AE60", danger_color = "#FFFFFF", danger_bg = "#E74C3C", danger_border = "#C0392B", link_disabled_color = "#95A5A6" ) )), titlePanel("Button Styles"), fluidRow( column(12, h3("Standard Buttons"), actionButton("btn1", "Default"), actionButton("btn2", "Primary", class = "btn-primary"), actionButton("btn3", "Success", class = "btn-success"), actionButton("btn4", "Danger", class = "btn-danger"), hr(), h3("Button Sizes"), actionButton("lg", "Large", class = "btn-primary btn-lg"), actionButton("md", "Medium", class = "btn-primary"), actionButton("sm", "Small", class = "btn-primary btn-sm"), actionButton("xs", "Extra Small", class = "btn-primary btn-xs") ) ) ) server <- function(input, output, session) {} if (interactive()) shinyApp(ui, server) ``` -------------------------------- ### Well Panel Styling with bs_vars_wells() Source: https://context7.com/dreamrs/fresh/llms.txt Shows how to customize well panel appearance using bs_vars_wells() to set background and border colors, commonly used for sidebar panels and content containers with custom styling. ```r library(fresh) library(shiny) # Customize well panels ui <- fluidPage( use_theme(create_theme( theme = "default", bs_vars_wells( bg = "#F8F9FA", border = "#3498DB" ), bs_vars_global( body_bg = "#FFFFFF" ) )), titlePanel("Well Panel Demo"), sidebarLayout( sidebarPanel( h4("Sidebar Controls"), sliderInput("slider", "Value:", 1, 100, 50), selectInput("select", "Choose:", choices = c("A", "B", "C")), checkboxInput("check", "Enable feature", TRUE) ), mainPanel( wellPanel( h4("Well Panel 1"), p("This is a well panel with custom background and border color.") ), wellPanel( h4("Well Panel 2"), plotOutput("plot", height = "200px") ) ) ) ) server <- function(input, output, session) { output$plot <- renderPlot({ barplot(c(3, 5, 7, 9), col = "#3498DB", border = NA) }) } if (interactive()) shinyApp(ui, server) ``` -------------------------------- ### Use Custom Shiny Theme Source: https://github.com/dreamrs/fresh/blob/master/README.md Applies a custom CSS theme to a Shiny application by specifying the theme file in the `theme` argument of `navbarPage` or `fluidPage`. ```r navbarPage( title = "My application", theme = "mytheme.css", ... ) ``` -------------------------------- ### Create bs4Dash Theme Source: https://github.com/dreamrs/fresh/blob/master/README.md Defines a custom theme for bs4Dash applications by specifying colors for primary, secondary, success, danger, sidebar, main background, body text, card backgrounds, and more. The created theme object can then be applied using the `use_theme()` function within a bs4Dash page. ```r bs4DashTheme <- bs4Dash_theme( primary = "#5E81AC", secondary = "#B48EAD", success = "#A3BE8C", danger = "#BF616A", "sidebar-light-bg" = "#3B4252", "sidebar-light-color" = "#E5E9F0", "main-bg" = "#2E3440", "body-color" = "#ECEFF4", "card-bg" = "#4C566A", # bs4Card() background "white" = "#E5E9F0", "info-box-bg" = "#4C566A", # bs4InfoBox() background dark = "#272c30", # bs4DashNavbar(status = "dark") background, "gray-600" = "#FFF" ) ``` -------------------------------- ### Tab Panel Styling with bs_vars_tabs() Source: https://context7.com/dreamrs/fresh/llms.txt Demonstrates tabbed navigation appearance customization using bs_vars_tabs() to control border colors, hover states, and active link styling for tabsetPanel components. ```r library(fresh) library(shiny) # Create custom tab styling ui <- fluidPage( use_theme(create_theme( theme = "default", bs_vars_tabs( border_color = "#E74C3C", link_hover_border_color = "#E74C3C", active_link_hover_bg = "#FFFFFF", active_link_hover_color = "#E74C3C", active_link_hover_border_color = "#E74C3C", justified_link_border_color = "#DDD", justified_active_link_border_color = "#E74C3C" ), bs_vars_color( brand_primary = "#E74C3C" ) )), titlePanel("Tabset Demo"), tabsetPanel( id = "maintabs", tabPanel("Overview", h3("Overview Section"), p("Content for overview tab with custom tab styling.") ), tabPanel("Data", h3("Data Section"), tableOutput("table") ), tabPanel("Visualization", h3("Charts"), plotOutput("chart") ), tabPanel("Settings", h3("Configuration"), p("Settings and preferences") ) ) ) server <- function(input, output, session) { output$table <- renderTable(head(mtcars, 5)) output$chart <- renderPlot({ barplot(table(mtcars$cyl), col = "#E74C3C", main = "Cylinders") }) } if (interactive()) shinyApp(ui, server) ``` -------------------------------- ### Create shinydashboard Theme Source: https://github.com/dreamrs/fresh/blob/master/README.md Generates a custom theme for shinydashboard applications. This function allows customization of specific AdminLTE color schemes, sidebar properties (like width and colors), and global settings for content and box backgrounds. The output is a theme object that can be applied using `use_theme()`. ```r mytheme <- create_theme( adminlte_color( light_blue = "#434C5E" ), adminlte_sidebar( width = "400px", dark_bg = "#D8DEE9", dark_hover_bg = "#81A1C1", dark_color = "#2E3440" ), adminlte_global( content_bg = "#FFF", box_bg = "#D8DEE9", info_box_bg = "#D8DEE9" ) ) ``` -------------------------------- ### Create AdminLTE Dashboard with Custom Colors Source: https://context7.com/dreamrs/fresh/llms.txt This snippet demonstrates how to create a shinydashboard application with a custom color theme using AdminLTE color definitions. It sets specific colors for elements like light_blue, aqua, green, purple, red, and yellow, and applies them to infoBox and valueBox elements within the dashboard body. Dependencies include the 'fresh' and 'shinydashboard' R packages. ```r library(fresh) library(shinydashboard) ui <- dashboardPage( header = dashboardHeader(title = "Sales Dashboard"), sidebar = dashboardSidebar( sidebarMenu( menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Widgets", tabName = "widgets", icon = icon("th")) ) ), body = dashboardBody( use_theme(create_theme( adminlte_color( light_blue = "#086A87", aqua = "#A9D0F5", green = "#0B3B0B", purple = "#610B4B", red = "#8B0000", yellow = "#FFD700" ) )), fluidRow( infoBox( "Orders", 1250, icon = icon("credit-card"), color = "light-blue" ), infoBox( "Revenue", "$58,460", icon = icon("dollar"), color = "green", fill = TRUE ), infoBox( "Conversion", "3.2%", icon = icon("line-chart"), color = "purple" ) ), fluidRow( valueBox( 5846, "New Orders", icon = icon("shopping-cart"), color = "aqua" ), valueBox( "92%", "Satisfaction", icon = icon("thumbs-up"), color = "green" ) ) ) ) server <- function(input, output, session) {} if (interactive()) shinyApp(ui, server) ``` -------------------------------- ### Apply bs4Dash Theme Source: https://github.com/dreamrs/fresh/blob/master/README.md Applies a custom theme to a bs4Dash application. The `use_theme()` function is called within the `bs4DashBody` to integrate the predefined theme object. ```r bs4DashPage( title = "bs4Dash custom theme", navbar = bs4DashNavbar(skin = "light"), sidebar = bs4DashSidebar( title = "bs4Dash custom theme", skin = "light", # ... ), body = bs4DashBody( use_theme(bs4DashTheme), # <-- use the theme # ... ) ) ``` -------------------------------- ### Apply shinydashboard Theme Source: https://github.com/dreamrs/fresh/blob/master/README.md Applies a custom theme object to a shinydashboard application. The `use_theme()` function is placed within the `dashboardBody` to integrate the created theme. ```r dashboardPage( header = dashboardHeader(title = "My dashboard"), sidebar = dashboardSidebar( # ... ), body = dashboardBody( use_theme(mytheme), # <-- use the theme # ... ) ) ``` -------------------------------- ### Create Theme with Custom Brand Color Palette Source: https://context7.com/dreamrs/fresh/llms.txt This code demonstrates how to define a custom brand color palette for a Shiny application using `fresh::bs_vars_color`. It allows setting primary, success, info, warning, and danger colors, as well as shades of gray. These colors can then be applied to various UI elements like buttons and alerts to maintain a consistent brand identity. Dependencies: 'fresh', 'shiny'. ```r library(fresh) library(shiny) ui <- fluidPage( use_theme(create_theme( theme = "default", bs_vars_color( gray_base = "#000000", gray_darker = "#222222", gray_dark = "#333333", gray = "#555555", gray_light = "#777777", gray_lighter = "#EEEEEE", brand_primary = "#E91E63", brand_success = "#4CAF50", brand_info = "#2196F3", brand_warning = "#FF9800", brand_danger = "#F44336" ) )), titlePanel("Brand Colors Demo"), sidebarLayout( sidebarPanel( actionButton("primary", "Primary", class = "btn-primary btn-block"), actionButton("success", "Success", class = "btn-success btn-block"), actionButton("info", "Info", class = "btn-info btn-block"), actionButton("warning", "Warning", class = "btn-warning btn-block"), actionButton("danger", "Danger", class = "btn-danger btn-block") ), mainPanel( tabsetPanel( tabPanel("Tab 1", div(class = "alert alert-success", "Success message"), div(class = "alert alert-info", "Info message"), div(class = "alert alert-warning", "Warning message"), div(class = "alert alert-danger", "Danger message") ), tabPanel("Tab 2", p("Content here")) ) ) ) ) server <- function(input, output, session) {} if (interactive()) shinyApp(ui, server) ``` -------------------------------- ### Generate Custom Bootstrap Theme with CSS Variables (R) Source: https://context7.com/dreamrs/fresh/llms.txt Generates a custom Bootstrap theme by compiling SCSS variables into a CSS file. This function allows for detailed customization of navbar, colors, states, and wells, and outputs a CSS file for use in Shiny applications. It requires the 'fresh' and 'shiny' libraries. ```r library(fresh) library(shiny) # Create a custom theme with navbar, colors, and component styling mytheme <- create_theme( theme = "default", bs_vars_navbar( default_bg = "#3f2d54", default_color = "#FFFFFF", default_link_color = "#FFFFFF", default_link_active_color = "#FFFFFF" ), bs_vars_color( gray_base = "#354e5c", brand_primary = "#75b8d1", brand_success = "#c9d175", brand_info = "#758bd1", brand_warning = "#d1ab75", brand_danger = "#d175b8" ), bs_vars_state( success_text = "#FFF", success_bg = "#c9d175", success_border = "#c9d175", info_text = "#FFF", info_bg = "#3f2d54", info_border = "#3f2d54", danger_text = "#FFF", danger_bg = "#d175b8", danger_border = "#d175b8" ), bs_vars_wells( bg = "#FFF", border = "#3f2d54" ), output_file = "www/mytheme.css" ) # Use in Shiny app ui <- navbarPage( title = "My Application", theme = "mytheme.css", tabPanel("Home", h1("Welcome"), actionButton("btn", "Primary Button", class = "btn-primary"), wellPanel("This is a well panel with custom styling") ), tabPanel("About", p("About page content")) ) server <- function(input, output, session) {} shinyApp(ui, server) ``` -------------------------------- ### Create Modern bs4Dash Theme with Custom Colors (R) Source: https://context7.com/dreamrs/fresh/llms.txt Generates a custom theme for bs4Dash applications using Bootstrap 4 variables and AdminLTE 3 styling. This function allows customization of primary, secondary, success, and danger colors, as well as specific elements like sidebar and body backgrounds and text colors. It requires the 'fresh' and 'bs4Dash' libraries. ```r library(fresh) library(bs4Dash) # Create a bs4Dash theme with custom colors and sidebar styling ui <- dashboardPage( header = dashboardHeader( status = "primary", title = dashboardBrand( title = "Analytics Dashboard", color = "primary" ) ), sidebar = dashboardSidebar( sidebarMenu( menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Reports", tabName = "reports", icon = icon("file")) ) ), body = dashboardBody( use_theme( bs4Dash_theme( primary = "#5E81AC", secondary = "#B48EAD", success = "#A3BE8C", danger = "#BF616A", "sidebar-light-bg" = "#3B4252", "sidebar-light-color" = "#E5E9F0", "main-bg" = "#2E3440", "body-color" = "#ECEFF4", "card-bg" = "#4C566A", "white" = "#E5E9F0", "info-box-bg" = "#4C566A" ) ), box(status = "primary", solidHeader = TRUE, title = "Metrics", p("Dashboard content here")), box(status = "success", solidHeader = TRUE, title = "Growth", plotOutput("plot1")) ), title = "Dashboard" ) server <- function(input, output, session) { output$plot1 <- renderPlot({ plot(mtcars$mpg, mtcars$wt, main = "Performance", col = "#A3BE8C", pch = 19) }) } if (interactive()) shinyApp(ui, server) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.