Access Dash DAQ component documentation
masterDetailed API documentation for all Dash DAQ components, including available properties and usage instructions, is available at the official Dash documentation site.
https://dash.plotly.com/dash-daqrepository·master·Indexed 40 days ago
https://github.com/plotly/dash-daqSpecialized Data Acquisition (DAQ) components for Dash version 0.6.0, designed for industrial and scientific dashboards. Includes components such as Gauge, Knob, LEDDisplay, PowerButton, Indicator, GraduatedBar, and ColorPicker, featuring a themed styling system and advanced color manipulation utilities.
Detailed API documentation for all Dash DAQ components, including available properties and usage instructions, is available at the official Dash documentation site.
https://dash.plotly.com/dash-daqTo use Dash DAQ components in your Dash applications, install the package via pip.
pip install dash_daqTo ensure that a user's selected value is not lost when the page is refreshed, use the persistence properties. The Knob component supports storing the value in different browser storage mechanisms.
persistence: (boolean | string | number) Enables persistence.persistence_type: Defines where the value is stored:'memory': Kept in memory; reset on page refresh.'local': Uses window.localStorage; persists even after the browser is closed.'session': Uses window.sessionStorage; cleared when the browser session ends.persisted_props: An array specifying which props to persist. For the Knob, this is typically ['value'].The library includes a robust color manipulation engine (based on colord) that allows for advanced color transformations. You can create new color instances from various formats and apply modifications.
#ffffff, #fff, #ffffff00 (hex8)rgb(255, 255, 255), rgba(255, 255, 255, 1)hsl(360, 100%, 50%)hsv(360, 100%, 100%)aliceblue, antiquewhite, aqua, etc.lighten(): Increases lightness.darken(): Decreases lightness.brighten(): Increases brightness.desaturate(): Reduces saturation.saturate(): Increases saturation.greyscale(): Converts to grayscale.spin(degrees): Rotates the hue.complement(): Returns the complementary color.triad(): Returns a triad of colors.analogous(): Returns analogous colors.monochromatic(): Returns monochromatic colors.splitcomplement(): Returns split-complementary colors.tetrad(): Returns tetradic colors.isDark() / isLight(): Checks brightness levels.getLuminance(): Returns the relative luminance.toRgb(), toHsl(), toHex(), toHsv(): Conversion methods.mix(color1, color2, ratio): Blends two colors.// Conceptual usage of color manipulation
const color = p('#ff0000');
const lighterColor = color.lighten();
const complementary = color.complement();
const mixed = p.mix('#ff0000', '#0000ff', 50); // 50% blendThe Slider component provides two primary ways to handle value updates via the updatemode prop:
mouseup (Default): The onChange event is triggered, but the component's internal state or the external Dash state is typically updated only when the interaction ends. This is efficient for preventing excessive callbacks during a drag.
drag: The component updates the value continuously as the user moves the handle. When using this mode, you must provide a setProps function to communicate the intermediate values back to the Dash application, otherwise the slider may appear to jump or reset.
updatemode: 'mouseup' | 'drag'setProps: A function used to update the component's props from within the component (essential for 'drag' mode).value: The current numeric value of the slider.// Example of continuous update using 'drag' mode
<Slider
updatemode="drag"
setProps={({ value }) => {
// This function is called during the drag to sync the value
console.log("Current value during drag:", value);
}}
/>To ensure a user's input is not lost when the page is refreshed, use the persistence and persistence_type props.
persistence: Set to True (or a truthy value) to enable persistence.persistence_type:'local': Uses window.localStorage; data persists even after the browser is closed.'session': Uses window.sessionStorage; data is cleared when the browser is closed.'memory': Data is kept in memory and reset on page refresh.# Example: Persisting the value in localStorage
daq_input = dash_daq.NumericInput(
id='persistent-input',
value=5,
persistence=True,
persistence_type='local'
)The Motion component (and its internal implementation Hs) provides support for CSS transitions and animations during the lifecycle of a component (appearing, entering, leaving, or disappearing).
Components using motion support several states:
appear: The initial mounting of the component.enter: Transitioning from hidden/non-existent to visible.leave: Transitioning from visible to hidden.none: A neutral state.motionName: A string or object defining the CSS class names used for different motion states.visible: Controls whether the component is currently visible.motionAppear, motionEnter, motionLeave: Booleans to enable/disable specific lifecycle animations.removeOnLeave: If true, the component will be removed from the DOM after the leave animation completes.leavedClassName: A CSS class applied to the component once it has finished its leave animation.onAppearStart, onAppearActive, onAppearEnd: Callbacks for the appearance lifecycle.onEnterStart, onEnterActive, onEnterEnd: Callbacks for the enter lifecycle.onLeaveStart, onLeaveActive, onLeaveEnd: Callbacks for the leave lifecycle.To ensure a user's selected color is preserved after a page refresh, use the persistence and persistence_type properties.
Available persistence_type options:
local: Uses window.localStorage; data persists even after the browser is closed.session: Uses window.sessionStorage; data is cleared when the browser is closed.memory: Data is kept only in memory and is reset on page refresh.dash_daq.ColorPicker(
id='persistent-picker',
persistence=True,
persistence_type='local'
)Dash DAQ components use a themed styling system. Components are rendered with specific CSS classes following a naming convention: daq-{component_name}--{theme_mode}, where {theme_mode} is either --light or --dark.
Theme colors are managed via a theme object. The default theme includes:
primary: #ABE2FBsecondary: #E6E6E6detail: #D3D3D3dark: false (default)Users can provide a custom theme object to override these values. If dark: true is set in the theme, components will use the --dark CSS variant.
// Conceptual representation of the naming convention
// <div class="daq-component-name--light"></div>
// <div class="daq-component-name--dark"></div>To display different labels for the 'on' and 'off' states, pass an array to the label property.
vertical is False: The first element is the left label, and the second is the right label.vertical is True: The first element is the bottom label, and the second is the top label.Labels can be simple strings or objects containing a label string and a style object.
# Example of dual labels with custom styling
dash_daq.ToggleSwitch(
id='dual-label-switch',
label=[
{'label': 'OFF', 'style': {'color': 'red'}},
{'label': 'ON', 'style': {'color': 'green'}}
]
)You can ensure that a user's toggle state is remembered even after a page refresh by using the persistence and persistence_type properties.
persistence: Set to True to enable persistence.persistence_type:'local': Uses window.localStorage (persists after browser close).'session': Uses window.sessionStorage (cleared when browser is closed).'memory': Kept only in memory (reset on page refresh).The Gauge component allows fine-grained control over how the scale (ticks and numbers) is rendered via the scale prop.
scale Prop Options:
start: (number) The starting value of the scale.interval: (number) The step size between labels.labelInterval: (number) How many intervals to skip before rendering a label.custom: (object) An object containing custom labels and styles for specific values.Label Positioning:
labelPosition: Can be set to 'top' or 'bottom' to determine where the main label is placed relative to the gauge.<Gauge
min={0}
max={100}
scale={{
start: 0,
interval: 10,
labelInterval: 2,
custom: {
50: { label: 'Midpoint', style: { fontWeight: 'bold' } }
}
}}
labelPosition="top"
/>