useSelectionAnnotationProps
Returns the border properties shared by the selected annotations and the functions for changing them.
const { isApplicable, borderColor, borderWidth } = useSelectionAnnotationProps()isApplicableistruewhen the selection contains at least one annotation that paints a border or a stroke (shapes, lines, ink, widgets); hide the controls otherwise.borderColorandborderWidthare selection props ({ value, set }, see useSelectionTextStyle for the pattern). The setters change every selected annotation with a border and skip the rest of the selection. For ink and lines, the border is the drawn stroke itself.borderColor.valueis aColorString('rgba(r,g,b,a)').borderColor.setaccepts common CSS color formats and normalizes them, and throwsInvalidInputErrorfor an unsupported format. The border opacity is carried in the color's alpha channel.borderWidthis in user-space units.- With no document loaded, the setters throw
DocumentNotLoadedError.
To edit other properties of the selected widgets, read them with useSelectedBlocks and update them with useSetWidgetProps.
Example
import { useSelectionAnnotationProps } from '@sdk-pdf/react'
function BorderWidthInput() {
const { isApplicable, borderWidth } = useSelectionAnnotationProps()
if (!isApplicable) return null
return (
<input
type="number"
min={0}
// An empty value means the selected annotations have different border widths.
value={borderWidth.value ?? ''}
onChange={(event) => borderWidth.set(Number(event.currentTarget.value))}
/>
)
}