Text Positioning
Precise positioning of text labels around diagram elements.
Overview
Precise positioning of text labels is essential for producing clear, readable diagrams. Neural Sketch provides intuitive positioning keys allowing exact placement of text around blocks and containers. Whether you're labeling network nodes, algorithm steps, or diagram annotations, these controls offer effortless fine-tuning.
Positioning Syntax
Neural Sketch uses an intuitive, compass-direction-based syntax
to precisely control text positioning and styling around diagram components.
Basic Text Positioning
Use the text-<compass-direction>
key to place text labels at specified compass directions relative to a shape. By default, the text is centered along the chosen compass direction.
Example:
This places the text "Hello" directly above the shape, centered horizontally.
Adjusting Text Alignment
To adjust horizontal or vertical alignment relative to the compass direction, append the -loc
suffix:
Valid alignments depend on the direction:
- For north/south positions, valid alignments are
west
,center
, andeast
. - For east/west positions, valid alignments are
north
,center
, andsouth
.
Example:
This aligns north-positioned text to the left (west).
Styling Text Labels
You can also inject custom styles into your text labels using the -style
suffix:
Example:
This example styles the north-positioned text label in bold and red.
Examples
Default Text Placement
By default, text labels are aligned at their respective compass directions (north, south, east, west) or centered within the block:
Adjusting Horizontal Alignment
Labels placed north or south can be adjusted horizontally (west
, east
, or center
). This is particularly useful when labels risk overlapping or you require a consistent horizontal alignment:
Adjusting Vertical Alignment
Similarly, labels placed east or west can be vertically aligned (north
, south
, or center
) to ensure readability and alignment precision:
Styled Text Labels
You can style text labels individually using the {direction}-style
key. This lets you highlight important labels or visually differentiate annotations:
Best Practices
- Use consistent alignment: Align related labels similarly for visual clarity.
- Avoid overlaps: Leverage positional adjustments to prevent labels from intersecting other diagram elements.
- Highlight with care: Sparingly use distinct styles for emphasis to maintain readability.
For further customization, explore Neural Sketch's global styling presets and palette options in the Package Options and Color Palette guides.
Reference
Prop | Type | Default |
---|---|---|
text-center? | token list | {} |
text-center-loc? | token list | {} |
text-center-style? | token list | {} |
text-east? | token list | {} |
text-east-loc? | token list | {} |
text-east-style? | token list | {} |
text-north? | token list | {} |
text-north-loc? | token list | {} |
text-north-style? | token list | {} |
text-south? | token list | {} |
text-south-loc? | token list | {} |
text-south-style? | token list | {} |
text-west? | token list | {} |
text-west-loc? | token list | {} |
text-west-style? | token list | {} |