<?xml version="1.0" encoding="utf-8"?>
<xbrl
  xmlns="http://www.xbrl.org/2003/instance"
  xmlns:dei="http://xbrl.sec.gov/dei/2026"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:xlink="http://www.w3.org/1999/xlink">
    <link:schemaRef xlink:href="trex-20260713.xsd" xlink:type="simple"/>
    <context id="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5">
        <entity>
            <identifier scheme="http://www.sec.gov/CIK">0001069878</identifier>
        </entity>
        <period>
            <startDate>2026-07-13</startDate>
            <endDate>2026-07-13</endDate>
        </period>
    </context>
    <dei:AmendmentFlag
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_4e9bdbc0-c3f7-4ae6-bc07-7e9fde3056de">false</dei:AmendmentFlag>
    <dei:EntityCentralIndexKey
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_adeafb9c-566c-4f89-96e8-759f5e8eafa9">0001069878</dei:EntityCentralIndexKey>
    <dei:DocumentType
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_14e81b94-c5fd-4d92-85a2-e77b213a4ecf">8-K</dei:DocumentType>
    <dei:DocumentPeriodEndDate
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_48a31088-0ed6-4c36-82f5-872bf5c54fe3">2026-07-13</dei:DocumentPeriodEndDate>
    <dei:EntityRegistrantName
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_906f71f0-b116-4b58-b07a-5aded932c436">Trex Company Inc</dei:EntityRegistrantName>
    <dei:EntityIncorporationStateCountryCode
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_9ad92557-f0b6-49ba-aa3d-d18f51a5559e">DE</dei:EntityIncorporationStateCountryCode>
    <dei:EntityFileNumber
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_40cde875-dc7c-4f12-82cd-eacbb4251fc7">001-14649</dei:EntityFileNumber>
    <dei:EntityTaxIdentificationNumber
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_6410340b-a70f-4549-9da2-338acfbfaf62">54-1910453</dei:EntityTaxIdentificationNumber>
    <dei:EntityAddressAddressLine1
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_357a6308-e7e1-40ef-abe1-88115fd5ac70">2500 Trex Way</dei:EntityAddressAddressLine1>
    <dei:EntityAddressCityOrTown
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_fb220af5-e6f0-4066-880b-0256e64bc7f9">Winchester</dei:EntityAddressCityOrTown>
    <dei:EntityAddressStateOrProvince
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_b7ea558f-7b40-4a25-8a1e-67e33218bc93">VA</dei:EntityAddressStateOrProvince>
    <dei:EntityAddressPostalZipCode
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_988504f7-eb4d-41ee-8204-6741a69e785a">22601</dei:EntityAddressPostalZipCode>
    <dei:CityAreaCode
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_38ac01da-1f27-4794-a307-655337509eb0">540</dei:CityAreaCode>
    <dei:LocalPhoneNumber
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_524df327-7790-49bf-83ac-fe540b7ddf95">542-6300 </dei:LocalPhoneNumber>
    <dei:WrittenCommunications
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_c2883aab-a13c-4477-9de6-8c77133a6b19">false</dei:WrittenCommunications>
    <dei:SolicitingMaterial
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_12648e50-e455-4c30-a98e-75dd6d57dac1">false</dei:SolicitingMaterial>
    <dei:PreCommencementTenderOffer
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_68db9044-4af3-447f-adf0-a088bd8f6367">false</dei:PreCommencementTenderOffer>
    <dei:PreCommencementIssuerTenderOffer
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_4465c754-39ee-4712-948f-e25f30ffb13d">false</dei:PreCommencementIssuerTenderOffer>
    <dei:Security12bTitle
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_744275a7-7a14-4459-8200-76b9240e1ec0">Common Stock </dei:Security12bTitle>
    <dei:TradingSymbol
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_a9150e2f-594f-4ceb-804b-e5d81559f0bb">TREX</dei:TradingSymbol>
    <dei:SecurityExchangeName
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_a95ccfca-5641-43ae-b129-a4ce12ecd8e4">NYSE</dei:SecurityExchangeName>
    <dei:EntityEmergingGrowthCompany
      contextRef="C_b35409ee-e4f9-411e-b59e-4b32d4997fd5"
      id="F_da33fff4-5468-4c0b-a6be-f9f7d7d5c198">false</dei:EntityEmergingGrowthCompany>
</xbrl>
