--- layout: default title: Slider control nav_order: 9 parent: Embed data and visualizations in your own website published: true permalink: /api/web_components/slider include_scripts: - /assets/js/syntax_highlighting.js - /assets/js/api-doc-tabs.js --- # Data Commons slider Web Component [Data Commons Web Component](/api/web_components/) for controlling the date in [datacommons-map](./map.md) or [datacommons-bar](./bar.md). ## Usage
```html ``` {: #map-tab .api-tabcontent} ```html ``` {: #bar-tab .api-tabcontent} ## Attributes ### Required | Name | Type | Description | | -------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | childPlaceType | string | Child place types of date range. Example: `State`. For a list of available place types, see the [place types page](/place_types.html).

optional if `dates` is specified. | | dates | list | Set date option range. Example: `"2001 2002 2003"`

optional if `variable`, `parentPlace`, and `childPlaceType` are specified. | | parentPlace | string | Parent place [DCID](/glossary.html#dcid) of date range. Example: `country/USA`.

optional if `dates` is specified. | | publish | string | Event name to publish on slider change. | | variable | string | Variable [DCID](/glossary.html#dcid) of date range. Example: `Count_Person`.

optional if `dates` is specified. | {: .doc-table } ### Optional | Name | Type | Description | | ------ | ------ | ----------------------------- | | header | string | Override default header text. | | value | number | Initial slider value. | {: .doc-table } ### Advanced Configuration | Name | Type | Description | | ------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------ | | apiRoot | string | Domain to make data fetch API calls from. Used primarily for fetching data from custom DCs.

Default: `https://datacommons.org`. | {: .doc-table } ## Examples ### Example 1: Use slider to change dates on a `datacommons-map` web component Code: {: .example-box-title} ```html ``` {: .example-box-content} ### Example 2: Use slider to change dates on a `datacommons-bar` web component Code: {: .example-box-title} ```html ``` {: .example-box-content}