Horizontal Rule type element in Addon Options Panel

I’m struggling to figure out how to properly integrate a Horizontal Rule type element with Center text in the Addon Options Panel. I’ve seen how it’s done in ACE, but I’d prefer to avoid using that library if at all possible. Any advice would be appreciated.

In Blizzard’s code this is defined in Blizzard_SettingsList.lua in SettingsListTemplate:

<Texture atlas="Options_HorizontalDivider" useAtlasSize="true">
	<Anchors>
		<Anchor point="TOP" y="-50"/>
	</Anchors>
</Texture>

In lua form:

f.divider = f:CreateTexture(nil,"ARTWORK")
f.divider:SetAtlas("Options_HorizontalDivider",true)
f.divider:SetPoint("TOP",0,-50)

Made into an addon settings with just a title and the line:

local f = CreateFrame("Frame")
Settings.RegisterAddOnCategory(Settings.RegisterCanvasLayoutCategory(f,"My AddOn"))

f.title = f:CreateFontString(nil,"ARTWORK","GameFontHighlightHuge")
f.title:SetPoint("TOPLEFT",7,-22)
f.title:SetText("My Addon Name")

f.divider = f:CreateTexture(nil,"ARTWORK")
f.divider:SetAtlas("Options_HorizontalDivider",true)
f.divider:SetPoint("TOP",0,-50)

Apologies for not being more specific, I figured out that part, thank you for posting the snippet though! What I’m trying to do is create an Hdiv that includes a centered text block within the Hdiv.

I was able to do it by drawing the lines and calculating the width of the rendered text to add padding, but I can’t figure out if there’s a better way to do it.

You center a fontstring by either giving it one anchor that’s TOP, CENTER or BOTTOM; or giving it a width (two anchors on opposing sides, or an actual width) and using the default CENTER justifyh.

f.title:SetPoint("TOP",0,-22)