# lv_switch.h (/api/widgets/switch/lv_switch_h)



<RelatedHeaders name="lv_switch_private.h" isPrivate="false" />

<ApiSummary functions="3" enums="2" macros="1" variables="1" />

Functions [#functions]

<ApiTabs items="[&#x22;Setters (1)&#x22;,&#x22;Getters (1)&#x22;,&#x22;Other (1)&#x22;]">
  <ApiTab value="Setters (1)">
    <ApiMember kind="function" name="lv_switch_set_orientation" file="widgets/switch/lv_switch.h" line="68" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/switch/lv_switch.h#L68">
      lv_switch_set_orientation [#lv_switch_set_orientation]

      Set the orientation of switch.

      ```c title=" " lineNumbers=1
      void lv_switch_set_orientation(lv_obj_t *obj, lv_switch_orientation_t orientation)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name          | Type                                             | Description                                       |
      | ------------- | ------------------------------------------------ | ------------------------------------------------- |
      | `obj`         | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to switch object                          |
      | `orientation` | <ApiLink name="lv_switch_orientation_t" />       | switch orientation from `lv_switch_orientation_t` |
    </ApiMember>
  </ApiTab>

  <ApiTab value="Getters (1)">
    <ApiMember kind="function" name="lv_switch_get_orientation" file="widgets/switch/lv_switch.h" line="79" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/switch/lv_switch.h#L79">
      lv_switch_get_orientation [#lv_switch_get_orientation]

      Get the orientation of switch.

      ```c title=" " lineNumbers=1
      lv_switch_orientation_t lv_switch_get_orientation(lv_obj_t *obj)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name  | Type                                             | Description              |
      | ----- | ------------------------------------------------ | ------------------------ |
      | `obj` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to switch object |

      **Returns:** <ApiLink name="lv_switch_orientation_t" /> — switch orientation from <ApiLink name="lv_switch_orientation_t" />
    </ApiMember>
  </ApiTab>

  <ApiTab value="Other (1)">
    <ApiMember kind="function" name="lv_switch_create" file="widgets/switch/lv_switch.h" line="57" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/switch/lv_switch.h#L57">
      lv_switch_create [#lv_switch_create]

      Create a switch object

      ```c title=" " lineNumbers=1
      lv_obj_t * lv_switch_create(lv_obj_t *parent)
      ```

      <span className="sr-only">
        Parameters
      </span>

      | Name     | Type                                             | Description                                                   |
      | -------- | ------------------------------------------------ | ------------------------------------------------------------- |
      | `parent` | <ApiLink name="lv_obj_t" display="lv_obj_t *" /> | pointer to an object, it will be the parent of the new switch |

      **Returns:** <ApiLink name="lv_obj_t" display="lv_obj_t *" /> — pointer to the created switch
    </ApiMember>
  </ApiTab>
</ApiTabs>

Enums [#enums]

<ApiMember kind="enum" name="_lv_property_switch_id_t" file="widgets/switch/lv_switch.h" line="32" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/switch/lv_switch.h#L32">
  \_lv_property_switch_id_t [#_lv_property_switch_id_t]

  | Name                             | Value                                                           |
  | -------------------------------- | --------------------------------------------------------------- |
  | `LV_PROPERTY_SWITCH_ORIENTATION` | `(LV_PROPERTY_SWITCH_START + ((int) 0 )) \| ((  1   ) <<  28 )` |
  | `LV_PROPERTY_SWITCH_END`         |                                                                 |
</ApiMember>

<ApiMember kind="enum" name="lv_switch_orientation_t" file="widgets/switch/lv_switch.h" line="42" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/switch/lv_switch.h#L42">
  lv_switch_orientation_t [#lv_switch_orientation_t]

  | Name                               |
  | ---------------------------------- |
  | `LV_SWITCH_ORIENTATION_AUTO`       |
  | `LV_SWITCH_ORIENTATION_HORIZONTAL` |
  | `LV_SWITCH_ORIENTATION_VERTICAL`   |
</ApiMember>

<TypeUsedBy name="lv_switch_orientation_t" count="1">
  * `lv_switch_set_orientation` — param `orientation`
</TypeUsedBy>

Macros [#macros]

<ApiMember kind="macro" name="LV_SWITCH_KNOB_EXT_AREA_CORRECTION" file="widgets/switch/lv_switch.h" line="27" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/switch/lv_switch.h#L27">
  LV_SWITCH_KNOB_EXT_AREA_CORRECTION [#lv_switch_knob_ext_area_correction]

  ```c title=" " lineNumbers=1
  #define LV_SWITCH_KNOB_EXT_AREA_CORRECTION 2
  ```

  Switch knob extra area correction factor
</ApiMember>

Variables [#variables]

<ApiMember kind="variable" name="lv_switch_class" file="widgets/switch/lv_switch.h" line="29" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/widgets/switch/lv_switch.h#L29">
  lv_switch_class [#lv_switch_class]

  ```c title=" " lineNumbers=1
  const lv_obj_class_t lv_switch_class
  ```
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_obj.h&#x22;]" includedBy="[&#x22;lv_switch_private.h&#x22;]" transitiveIncludes="[&#x22;lv_anim.h&#x22;, &#x22;lv_area.h&#x22;, &#x22;lv_array.h&#x22;, &#x22;lv_assert.h&#x22;, &#x22;lv_bidi.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_color_op.h&#x22;, &#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_display.h&#x22;, &#x22;lv_draw.h&#x22;, &#x22;lv_draw_arc.h&#x22;, &#x22;lv_draw_blur.h&#x22;, &#x22;lv_draw_buf.h&#x22;, &#x22;lv_draw_image.h&#x22;, &#x22;lv_draw_label.h&#x22;, &#x22;lv_draw_line.h&#x22;, &#x22;lv_draw_rect.h&#x22;, &#x22;lv_draw_triangle.h&#x22;, &#x22;lv_event.h&#x22;, &#x22;lv_ext_data.h&#x22;, &#x22;lv_flex.h&#x22;, &#x22;lv_font.h&#x22;, &#x22;lv_fs.h&#x22;, &#x22;lv_grad.h&#x22;, &#x22;lv_grid.h&#x22;, &#x22;lv_group.h&#x22;, &#x22;lv_image_decoder.h&#x22;, &#x22;lv_image_dsc.h&#x22;, &#x22;lv_indev.h&#x22;, &#x22;lv_layout.h&#x22;, &#x22;lv_ll.h&#x22;, &#x22;lv_log.h&#x22;, &#x22;lv_math.h&#x22;, &#x22;lv_matrix.h&#x22;, &#x22;lv_mem.h&#x22;, &#x22;lv_obj_class.h&#x22;, &#x22;lv_obj_draw.h&#x22;, &#x22;lv_obj_event.h&#x22;, &#x22;lv_obj_pos.h&#x22;, &#x22;lv_obj_property.h&#x22;, &#x22;lv_obj_property_names.h&#x22;, &#x22;lv_obj_scroll.h&#x22;, &#x22;lv_obj_style.h&#x22;, &#x22;lv_obj_style_gen.h&#x22;, &#x22;lv_obj_tree.h&#x22;, &#x22;lv_palette.h&#x22;, &#x22;lv_profiler.h&#x22;, &#x22;lv_profiler_builtin.h&#x22;, &#x22;lv_sprintf.h&#x22;, &#x22;lv_string.h&#x22;, &#x22;lv_style.h&#x22;, &#x22;lv_style_gen.h&#x22;, &#x22;lv_style_properties.h&#x22;, &#x22;lv_symbol_def.h&#x22;, &#x22;lv_text.h&#x22;, &#x22;lv_tick.h&#x22;, &#x22;lv_timer.h&#x22;, &#x22;lv_types.h&#x22;]" />
