Skip to content

Commit a11d664

Browse files
committed
Adds accessibility to Markdown Headers. Users that have Talkback enabled on there android device will be able to Navigate by headings.
1 parent 5454726 commit a11d664

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui

richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/Heading.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ import androidx.compose.ui.Modifier
1111
import androidx.compose.ui.graphics.Color
1212
import androidx.compose.ui.graphics.takeOrElse
1313
import androidx.compose.ui.platform.LocalLayoutDirection
14+
import androidx.compose.ui.semantics.heading
15+
import androidx.compose.ui.semantics.semantics
1416
import androidx.compose.ui.text.TextStyle
1517
import androidx.compose.ui.text.font.FontStyle.Companion.Italic
1618
import androidx.compose.ui.text.font.FontWeight
1719
import androidx.compose.ui.text.resolveDefaults
1820
import androidx.compose.ui.unit.sp
1921

22+
2023
/**
2124
* Function that computes the [TextStyle] for the given header level, given the current [TextStyle]
2225
* for this point in the composition. Note that the [TextStyle] passed into this function will be
@@ -70,7 +73,7 @@ internal val DefaultHeadingStyle: HeadingStyle = { level, textStyle ->
7073
text: String
7174
) {
7275
Heading(level) {
73-
Text(text)
76+
Text(text, Modifier.semantics { heading() })
7477
}
7578
}
7679

0 commit comments

Comments
 (0)