---
title: "HorizontalRuler"
description: "A horizontal [Ruler]. Defines a line that can be used by parent layouts to align or position
their children vertically. The position of the ruler can be retrieved with
[Placeable.PlacementScope.current] and can be set with [MeasureScope.layout] using
[RulerScope.provides]."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
class HorizontalRuler private constructor(calculation: (PlacementScope.(Float) -> Float)?) :
    Ruler(calculation)
```


A horizontal `Ruler`. Defines a line that can be used by parent layouts to align or position
their children vertically. The position of the ruler can be retrieved with
`Placeable.PlacementScope.current` and can be set with `MeasureScope.layout` using
`RulerScope.provides`.


## Secondary Constructors

```kotlin
constructor() : this(null)
```


Creates a `HorizontalRuler` whose values are directly provided. The developer can set the
ruler value in `MeasureScope.layout` using `RulerScope.provides` or
`RulerScope.providesRelative`.


## Companion Object

#### Methods

<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun maxOf(vararg rulers: HorizontalRuler) = HorizontalRuler { defaultValue ->
            mergeRulerValues(true, rulers, defaultValue)
        }
```


Creates a `HorizontalRuler` derived from the greater value of all `HorizontalRuler`s in
`rulers` that supply a value. This is the right-most of all provided ruler values.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun minOf(vararg rulers: HorizontalRuler) = HorizontalRuler { defaultValue ->
            mergeRulerValues(false, rulers, defaultValue)
        }
```


Creates a `HorizontalRuler` derived from the least value of all `HorizontalRuler`s in
`rulers` that supply a value. This is the left-most of all provided ruler values.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun derived(calculation: PlacementScope.(defaultValue: Float) -> Float) =
            HorizontalRuler(calculation)
```


Creates a `HorizontalRuler` whose values are derived from values available in the
`PlacementScope`, such as other `HorizontalRuler`s.

#### Parameters

| | |
| --- | --- |
| calculation | A function that calculates the value of the ruler |






