Skip to content

Commit fd23bc0

Browse files
authored
Components as props in labels (#940)
1 parent 397830d commit fd23bc0

File tree

13 files changed

+93
-14
lines changed

13 files changed

+93
-14
lines changed

dash_bootstrap_components/icons.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BOOTSTRAP = (
2-
"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/"
2+
"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/"
33
"font/bootstrap-icons.css"
44
)
5-
FONT_AWESOME = "https://use.fontawesome.com/releases/v6.1.1/css/all.css"
5+
FONT_AWESOME = "https://use.fontawesome.com/releases/v6.3.0/css/all.css"

docs/components_page/components/input.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ If you need more granular control over checkboxes and radio buttons, you can als
108108

109109
{{example:components/input/radio_check_standalone.py:standalone_radio_check}}
110110

111+
## Components in labels
112+
113+
You can include components in labels for `Checklist`, `RadioItems`, `Checkbox`, `RadioButton`, and `Switch`.
114+
115+
{{example:components/input/components_in_labels.py:components_in_labels}}
116+
117+
111118
## Color picker
112119

113120
When using `Input` with `type="color"`, the user may specify a color, either by using a visual color picker or by entering the color in a text field in #rrggbb format.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import dash_bootstrap_components as dbc
2+
from dash import html
3+
4+
flights = html.Div([html.I(className="bi bi-airplane pe-1"), "Flights"])
5+
car = html.Div([html.I(className="bi bi-car-front pe-1"), "Rental Car"])
6+
hotel = html.Div([html.I(className="bi bi-house pe-1"), "Hotel"])
7+
8+
radioitems = html.Div(
9+
[
10+
dbc.Label("Booking"),
11+
dbc.RadioItems(
12+
options=[
13+
{"label": flights, "value": 1},
14+
{"label": car, "value": 2},
15+
{"label": hotel, "value": 3},
16+
],
17+
value=1,
18+
id="radioitems-input",
19+
),
20+
]
21+
)
22+
23+
checkbox = dbc.Checkbox(
24+
id="standalone-checkbox",
25+
label=html.Div(
26+
["I agree to the ", html.A("Terms and Conditions", href="#")]
27+
),
28+
value=False,
29+
)
30+
31+
components_in_labels = html.Div([radioitems, html.Hr(), checkbox])

docs/templates/partials/head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
/>
1818
<link
1919
rel="stylesheet"
20-
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css"
20+
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/font/bootstrap-icons.css"
2121
/>

noxfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"dash_bootstrap_components",
77
"docs",
88
"examples",
9+
"tests",
910
"noxfile.py",
1011
"tasks.py",
1112
]

src/components/input/Checkbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Checkbox.propTypes = {
125125
/**
126126
* The label of the <input> element
127127
*/
128-
label: PropTypes.string,
128+
label: PropTypes.node,
129129

130130
/**
131131
* The id of the label

src/components/input/Checklist.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ Checklist.propTypes = {
190190
/**
191191
* The checkbox's label
192192
*/
193-
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
194-
.isRequired,
193+
label: PropTypes.node.isRequired,
195194

196195
/**
197196
* The value of the checkbox. This value corresponds to the items

src/components/input/RadioButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ RadioButton.propTypes = {
126126
/**
127127
* The label of the <input> element
128128
*/
129-
label: PropTypes.string,
129+
label: PropTypes.node,
130130

131131
/**
132132
* The id of the label

src/components/input/RadioItems.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ RadioItems.propTypes = {
184184
/**
185185
* The radio item's label
186186
*/
187-
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
188-
.isRequired,
187+
label: PropTypes.node.isRequired,
189188

190189
/**
191190
* The value of the radio item. This value corresponds to the items

src/components/input/Switch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Switch.propTypes = {
125125
/**
126126
* The label of the <input> element
127127
*/
128-
label: PropTypes.string,
128+
label: PropTypes.node,
129129

130130
/**
131131
* The id of the label

0 commit comments

Comments
 (0)