Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion docs/components_page/components/button.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,38 @@ Modify the size of the button by setting `size` to either `"sm"` or `"lg"` for a
## Block button

Create a Bootstrap 4 style block level button (one which spans the full width
of the parent) by using Bootstrap's grid spacing utilities.
of the parent) by using Bootstrap's [spacing utility classes](https://getbootstrap.com/docs/5.0/utilities/spacing/).

{{example:components/button/block.py:button}}

## Smaller block buttons

You can adjust the width of the block button can be achieved using grid column width classes. This button is made half-size using `.col-6` and centered with `.mx-auto`.

{{example:components/button/half_block.py:button}}

## Responsive block buttons

A responsive variation on the block button can be created by making using of breakpoints to specify behaviour. Resize your screen to see how adding the `d-md-block` class changes the button behaviour on smaller screens.

{{example:components/button/responsive_block.py:button}}

## Flex layout

Flex and margin utilities can be used to adjust the alignment of the buttons in their horizontal state too. Here we use them in conjuction with the responsive block button above to control the layout on larger and smaller screens.

{{example:components/button/flex_block.py:button}}

## Active and disabled states

When a user hovers the cursor over a button the background and border will darken in response. You can enforce this active state if needed by setting `active=True`.

{{example:components/button/active_disabled.py:buttons}}

## Download option

The `download` prop allows you to specify the filename for a downloaded file that can differ from the filename on the server.

{{example:components/button/download.py:button}}

{{apidoc:src/components/Button.js}}
15 changes: 15 additions & 0 deletions docs/components_page/components/button/download.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
library(dashBootstrapComponents)
library(dashHtmlComponents)


button <- htmlDiv(
list(
dbcButton(
"Download",
href = "/static/data_file.txt",
download = "my_data.txt",
external_link = TRUE,
color = "primary"
)
)
)
11 changes: 11 additions & 0 deletions docs/components_page/components/button/download.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using DashBootstrapComponents, DashHtmlComponents

button = html_div([
dbc_button(
"Download",
href = "/static/data_file.txt",
download = "my_data.txt",
external_link = true,
color = "primary",
),
])
14 changes: 14 additions & 0 deletions docs/components_page/components/button/download.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import dash_bootstrap_components as dbc
import dash_html_components as html

button = html.Div(
[
dbc.Button(
"Download",
href="/static/data_file.txt",
download="my_data.txt",
external_link=True,
color="primary",
),
]
)
11 changes: 11 additions & 0 deletions docs/components_page/components/button/flex_block.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
library(dashBootstrapComponents)
library(dashHtmlComponents)

button <- htmlDiv(
list(
dbcButton("Button 1", class_name = "me-md-2"),
dbcButton("Button 2", class_name = "me-md-2"),
dbcButton("Button 3")
),
class_name = "d-grid gap-2 d-md-flex justify-content-md-end"
)
11 changes: 11 additions & 0 deletions docs/components_page/components/button/flex_block.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using DashBootstrapComponents
using DashHtmlComponents

button = html_div(
[
dbc_button("Button 1", class_name = "me-md-2"),
dbc_button("Button 2", class_name = "me-md-2"),
dbc_button("Button 3"),
],
class_name = "d-grid gap-2 d-md-flex justify-content-md-end",
);
11 changes: 11 additions & 0 deletions docs/components_page/components/button/flex_block.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import dash_bootstrap_components as dbc
import dash_html_components as html

button = html.Div(
[
dbc.Button("Button 1", class_name="me-md-2"),
dbc.Button("Button 2", class_name="me-md-2"),
dbc.Button("Button 3"),
],
class_name="d-grid gap-2 d-md-flex justify-content-md-end",
)
10 changes: 10 additions & 0 deletions docs/components_page/components/button/half_block.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library(dashBootstrapComponents)
library(dashHtmlComponents)

button <- htmlDiv(
list(
dbcButton("Block button", color = "primary"),
dbcButton("Block button", color = "secondary")
),
class_name = "d-grid gap-2 col-6 mx-auto"
)
10 changes: 10 additions & 0 deletions docs/components_page/components/button/half_block.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using DashBootstrapComponents
using DashHtmlComponents

button = html_div(
[
dbc_button("Block button", color = "primary"),
dbc_button("Block button", color = "secondary"),
],
class_name = "d-grid gap-2 col-6 mx-auto",
);
10 changes: 10 additions & 0 deletions docs/components_page/components/button/half_block.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import dash_bootstrap_components as dbc
import dash_html_components as html

button = html.Div(
[
dbc.Button("Block button", color="primary"),
dbc.Button("Block button", color="secondary"),
],
class_name="d-grid gap-2 col-6 mx-auto",
)
10 changes: 10 additions & 0 deletions docs/components_page/components/button/responsive_block.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library(dashBootstrapComponents)
library(dashHtmlComponents)

button <- htmlDiv(
list(
dbcButton("Block button", color = "primary"),
dbcButton("Block button", color = "secondary")
),
class_name = "d-grid gap-2 d-md-block"
)
10 changes: 10 additions & 0 deletions docs/components_page/components/button/responsive_block.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using DashBootstrapComponents
using DashHtmlComponents

button = html_div(
[
dbc_button("Block button", color = "primary"),
dbc_button("Block button", color = "secondary"),
],
class_name = "d-grid gap-2 d-md-block",
);
10 changes: 10 additions & 0 deletions docs/components_page/components/button/responsive_block.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import dash_bootstrap_components as dbc
import dash_html_components as html

button = html.Div(
[
dbc.Button("Block button", color="primary"),
dbc.Button("Block button", color="secondary"),
],
class_name="d-grid gap-2 d-md-block",
)
12 changes: 12 additions & 0 deletions docs/components_page/components/button_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ Instead of setting the `size` prop of each button in the group, you can set the

{{example:components/button_group/size.py:button_groups}}

## Mixed styles

You can apply styles to individual buttons within the group.

{{example:components/button_group/mixed.py:button_group}}

## Outline style

Create a group of outline buttons using `outline=True` and setting the `color` as required.

{{example:components/button_group/outline.py:button_group}}

## Dropdown

As well as `Button` you can include `DropdownMenu` in your button groups by setting `group=True`.
Expand Down
9 changes: 9 additions & 0 deletions docs/components_page/components/button_group/mixed.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library(dashBootstrapComponents)

button_group <- dbcButtonGroup(
list(
dbcButton("Left", color = "danger"),
dbcButton("Middle", color = "warning"),
dbcButton("Right", color = "success")
)
)
7 changes: 7 additions & 0 deletions docs/components_page/components/button_group/mixed.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using DashBootstrapComponents

button_group = dbc_buttongroup([
dbc_button("Left", color = "danger"),
dbc_button("Middle", color = "warning"),
dbc_button("Right", color = "success"),
])
9 changes: 9 additions & 0 deletions docs/components_page/components/button_group/mixed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import dash_bootstrap_components as dbc

button_group = dbc.ButtonGroup(
[
dbc.Button("Left", color="danger"),
dbc.Button("Middle", color="warning"),
dbc.Button("Right", color="success"),
]
)
9 changes: 9 additions & 0 deletions docs/components_page/components/button_group/outline.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library(dashBootstrapComponents)

button_group <- dbcButtonGroup(
list(
dbcButton("Left", outline = TRUE, color = "primary"),
dbcButton("Middle", outline = TRUE, color = "primary"),
dbcButton("Right", outline = TRUE, color = "primary")
)
)
7 changes: 7 additions & 0 deletions docs/components_page/components/button_group/outline.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using DashBootstrapComponents

button_group = dbc_buttongroup([
dbc_button("Left", outline = true, color = "primary"),
dbc_button("Middle", outline = true, color = "primary"),
dbc_button("Right", outline = true, color = "primary"),
])
9 changes: 9 additions & 0 deletions docs/components_page/components/button_group/outline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import dash_bootstrap_components as dbc

button_group = dbc.ButtonGroup(
[
dbc.Button("Left", outline=True, color="primary"),
dbc.Button("Middle", outline=True, color="primary"),
dbc.Button("Right", outline=True, color="primary"),
]
)
1 change: 1 addition & 0 deletions docs/static/data_file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is an example data file used to demonstrate the download option in Buttons.